1. Create a new user
Login mysql@>mysql-u root-p@> Password//create user mysql> insert into Mysql.user (Host,user,password) VALUES ("localhost", " Phplamp ", Password (" 1234 "));//Refresh the System permissions table Mysql>flush privileges; This creates a user named: Phplamp Password: 1234 . Then log in. Ps:2 Point Pit, 1, there may be anonymous users in the new database that need to be deleted or will not be logged in correctly. reference:http://stackoverflow.com/questions/10299148/ MYSQL-ERROR-1045-28000-ACCESS-DENIED-FOR-USER-BILLLOCALHOST-USING-PASSW;2 values in the password to use the password package, otherwise you can not log in normally. (not yet know why) mysql>exit;@>mysql-u phplamp-p@> Enter password mysql> login successful
2 User Authorization
Log in to MySQL (with root privileges). I am logged in as root.//must be logged in by the administrator of the root authority only. @>mysql-u root-p@> Password//First create a database for the user (phplampdb) mysql>create db phplampdb;// Authorizes the Phplamp user to have all the permissions of the Phplamp database. >grant all privileges in phplampdb.* to [e-mail protected] identified by ' 1234 ';//Refresh System Permissions Table// Actions such as authorization to refresh the permissions table or restart the MySQL server Mysql>flush privileges;mysql> Other actions/* If you want to specify partial permissions to a user, you can write: Mysql>grant Select , update on phplampdb.* to [e-mail protected] identified by ' 1234 ';//Refresh the System permissions table. Mysql>flush privileges;*/
Reduce user Rights
>revoke alter,select on books.* from test;
Revoke all permissions
>revoke all on books.* from test
3 Deleting a user
@>mysql-u root-p@> password mysql>delete from mysql.user WHERE user= "Phplamp" and host= "localhost"; mysql>flush privileges;
4 Modifying user passwords
@>mysql-u root-p@> password mysql>update mysql.user set Password=password (' New password ') where user= "Phplamp" and Host= " localhost "; mysql>flush privileges;
The basic operation of MySQL