1. Create a new normal user
--create statements
mysql> create user ' test1 ' @ ' localhost ' identified by ' test1 ';
--Inserting with insert
mysql> INSERT INTO Mysql.user (host,user,password,ssl_cipher,x509_issuer,x509_subject) VALUES (' localhost ', ' test2 ', password (' test2 '), ', ', ', ');
mysql> flush Privileges;
--Using the GRANT statement
Mysql> Grant SELECT On * * to ' test3 ' @ ' localhost ' identified by ' test3 ';
mysql> flush Privileges;
2. Delete a normal user
--drop Delete
mysql> drop user ' test1 ' @ ' localhost ';
--Delete from table using delete
Mysql> Delete from mysql.user where host= ' localhost ' and user= ' test2 ';
mysql> flush Privileges;
3.root Change Password
----root to change the root password
--mysqladmin modification
[Email protected] ~]# mysqladmin-uroot-p password
Enter Password:
New Password:
Confirm New Password:
--Use Update to change after login
mysql> Update Mysql.user Set Password=password (' root ') where host= ' localhost ' and user= ' root ';
mysql> flush Privileges;
--use Set to modify after login
Mysql> set Password=password (' root ')
mysql> flush Privileges;
----ROOT to modify a normal user password
--set statements
mysql> set password for ' test3 ' @ ' localhost ' =password (' test3 ');
--update Update Mysql.user Table
mysql> Update Mysql.user Set Password=password (' Test3 ') where host= ' localhost ' and user= ' test3 ';
mysql> flush Privileges;
--grant statements
Mysql> Grant SELECT On * * to ' test3 ' @ ' localhost ' identified by ' test3 ';
After Grant modifies the password, the previous authorization for the user to use the old password is still
4. Ordinary users to change their own password
Mysql> set Password=password (' test4 ');
Ordinary users generally cannot use Mysqladmin
5.root Password Loss
[Email protected] ~]# VIM/ETC/MY.CNF
[Mysqld]
Skip-grant-tables
[Email protected] ~]#/etc/init.d/mysqld restart
[[email protected] ~]# MySQL
Mysql>
mysql> Update Mysql.user Set Password=password (' root ') where host= ' localhost ' and user= ' root ';
mysql> flush Privileges;
Note: Use mysql-5.5.30
This article is from the "popular sui" blog, please be sure to keep this source http://8722413.blog.51cto.com/8712413/1542400