Getting started with MySQL user management (add, delete, and permission)

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.