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).