Here is a detailed manual on how to create a new user and grant permissions in MySQL:
To create a new user and grant permissions in MySQL, you must log in to your MySQL server. You can do this in a number of ways, but a common way is to open a terminal or command line and type the following:
mysql -u root -p
This will log into MySQL with the user root. It will ask you to enter your root password before continuing.
Once you are logged into MySQL, you can create a new user using the following command:
´CREATE ´USER 'nombre_de_usuario'@'localhost' IDENTIFIED BY 'contraseña';
In this command, you must replace username with the username you want to create and password with the password you want to assign to that user.
Once you have created the user, you must grant them permissions so that they can interact with the databases. You can do this using the following command:
GRANT permiso ON nombre_de_base_de_datos.* TO 'nombre_de_usuario'@'localhost';
In this command, permission represents the type of permission you want to grant, such as SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, INDEX, etc. nombre_de_base_de_datos is the name of the database you want to grant permissions on, and nombre_de_usuario is the user name you want to grant permissions to.
You can grant multiple permissions by separating them by commas. For example, if you want to grant SELECT and INSERT permissions on the my_database to the user my_user, you can use the following command:
GRANT SELECT, INSERT ON my_database.* TO 'my_user'@'localhost';
Once you have granted permissions to the new user, you must update the permissions in MySQL for them to take effect. You can do this using the following command:
FLUSH PRIVILEGES;
This command will update the permissions in MySQL so that the newly created user can interact with the databases.
Once you have created a new user and granted permissions, you can exit MySQL using the following command:
exit
This will log out of MySQL and return to the terminal or command line.
success Done! You have now created a new user and given it permissions to interact with the databases in MySQL.
Discover the most powerful and flexible way to manage your servers. Leave us your email and we'll send you the steps to get started in minutes.
Already have an account? Log In