In mysql user management, we mainly talked about how to add, delete, Set passwords, delete, and set permissions for mysql users. If you have any questions, please do not go to the reference page.
Add User
Local access permission: mysql> grant all privileges on *. * TO 'username
'@ 'Localhost'
-> Identified by 'Password' with grant option;
Remote access permission: mysql> grant all privileges on *. * TO 'username' @ '%'
-> Identified by 'Password' with grant option;
Another method is to directly Insert INTO user. Note that this method requires flush privileges to allow the server to re-read the authorization table. Delete a user
Drop user user; restrict USER resources
Mysql> grant all on customer. * TO 'francis '@ 'localhost'
-> Identified by 'frank'
-> WITH MAX_QUERIES_PER_HOUR 20
-> MAX_UPDATES_PER_HOUR 10
-> MAX_CONNECTIONS_PER_HOUR 5
-> MAX_USER_CONNECTIONS 2;
Set User Password
Command Line: shell> mysqladmin-u user_name-h host_name password "newpwd" or execute the statement: mysql> set password for 'username' @ '%'
= PASSWORD ('Password ');
If you only need to change your PASSWORD, you can directly: mysql> set password = password ('Password ');
At the global level, use the grant usage statement (in *. *) TO specify the password of an account: mysql> grant usage on *. * TO 'username' @ '%'
Identified by 'Password ';
Or directly modify the MySQL database table: mysql> UPDATE user SET Password = PASSWORD ('bagel ')
-> WHERE Host = '%' AND User = 'francis ';
Mysql> flush privileges;
About Encryption
Mysql> select PASSWORD ('Password ');
+ ------------------------------------------- +
| PASSWORD ('Password') |
+ ------------------------------------------- +
| * 2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+ ------------------------------------------- +
1 row in set (0.00 sec)
Mysql> select MD5 ('hello ');
+ ---------------------------------- +
| MD5 ('hello') |
+ ---------------------------------- +
| 5d41402abc4b2a76b9719d911017c592 |
+ ---------------------------------- +
1 row in set (0.00 sec)
Mysql> select SHA1 ('abc ');
-> 'A9993e364706816aba3e25717850c26c9cd0d89d'
SHA1 () calculates a SHA1 160 bits check and for the string, as described in RFC 3174 (security hashing algorithm.