1. Log in to MySQL
#mysql-U root-p
2. New users
Insert into Mysql.user (Host,user,password) VALUES ("localhost", "xxx", Password ("* * *"));
Note: XXX is a new user name, * * * user password
3. After executing the sentence, you also need to refresh the permission table
Flush privileges;
4. Create a new database and give users permissions
Create Database dbtest;
All licenses:
Allow log on locally
Grant all privileges the dbtest.* to [e-mail protected] identified by "*";
Allow any host to log on
Grant all privileges on dbtest. To [e- mail protected] '% ' identifiedby ';
Partial authorization:
Grant Select,update on dbtest.* to [e-mail protected] identified by "* * *";
5. Grant permissions, and then refresh the permissions table
Flush privileges;
6. Query for new results with SQL statements
Select User,host,password from Mysql.user;
7. Delete a user
Delete from user where user= ' xxx ';
Flush privileges;
8. Deleting a database
Drop database dbtest;
9. Change the password
Update Mysql.user set Password=password (' New password ') where user= ' xxx ' and host= ' localhost ';
Flush privileges;
Linux environment MySQL new user and database and authorize