MySQL Getting Started Tutorial user management (Add, delete, permissions)

Source: Internet
Author: User

Add user

Native access Permissions:mysql> GRANT all privileges on *.* to ' username
' @ ' localhost '

-> identified by ' password ' with GRANT OPTION;
Remote access permission:mysql> GRANT all privileges in *.* to ' username ' @ '% '

-> identified by ' password ' with GRANT OPTION;
Another method is to insert into user directly, note that this method requires FLUSH privileges to let the server reread the authorization table. Delete User
DROP user user, restricting users 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 statement:mysql> SET password for ' username ' @ '% '
= PASSWORD (' PASSWORD ');
If you only change your password, direct:mysql> SET PASSWORD = PASSWORD (' PASSWORD ');
Use the GRANT USAGE statement (in *.*) at the global level to specify the password for an account:mysql> GRANT USAGE on *.* to ' username ' @ '% '
Identified by ' password ';
or directly modify the MySQL library 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 () is a SHA1 160 bit check for the string, as described in RFC 3174 (Security hashing algorithm).

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.