The code is as follows |
Copy Code |
Mysql-u root-p mysql> use MySQL; Mysql> grant all privileges in *.* to root@ '% ' identified by ' root '; Mysql> select Host,user,password from user; + ———— –+--+ ——————————————-+ | Host | user | password | + ———— –+--+ ——————————————-+ | localhost | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b | | 192.168.1.12 | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b | | % | Root | *81f5e21e35407d884a6cd4a731aebfb6af209e1b | + ———— –+--+ ——————————————-+ 3 Rows in Set (0.00 sec) mysql> flush Privileges; |
Authorization law:
For example, you want to myuser use MyPassword to connect to a MySQL server from any host.
The code is as follows |
Copy Code |
Mysql> grant all privileges in *.* to identified by ' MyPassword ' with GRANT OPTION; |
If you want to allow the user to connect to the MySQL server from the IP-192.168.1.6 host, and use MyPassword as the password myuser
The code is as follows |
Copy Code |
Mysql> grant all privileges in *.* to ' myuser ' @ ' 192.168.1.3′identified by ' mypassword ' with GRANT OPTION; |
Attention:
1, Format: Grant permissions on the database name. Table name to user @ Login host identified by "User password";
2, is the new root is not modified, if the localhost to%, then the local can not connect to the MySQL through localhost;
3, refresh the MySQL system permissions related table flush privileges;
More relevant open MySQL remote connection can refer to: http://www.111cn.net/database/mysql/34989.htm