This article mainly introduces how to add new users to your MySQL database. Because a mysql may have many databases, we need to grant permissions to different databases and enable users, this is necessary.
How to add a new user to your mysql tutorial database tutorial
This article mainly introduces how to add new users to your mysql database. Because a mysql may have many databases, we need to grant permissions to different databases and enable users, this is necessary.
Create user [identified by [password] 'Password']
Instance
Create user 'user1' @ 'localhost' identified by 'pass1 ';
If you check the mysql. user table, you can find a new record in it. Please note that all priviliges are loaded so this user can be irrelevant to the database. To add some preiviliges, we can use the grant command as follows:
Grant select, insert, update, delete on *. * to 'user1' @ 'localhost ';
We only added the most important priviliges to the user, but the table cannot be created above,
Grant all on *. * to 'user1' @ 'localhost ';
Grant all on *. * to 'user2' @ 'localhost' identified by 'pass1 ';
You can save data to a table.
Insert into user (host, user, password) values ('localhost', 'user3', password ('passs3 '));