New Method
- We now add a ' username ' user with a password of ' password ', allowing it to access MySQL from outside.
1 Grant all on * to ' username ' identified by ' password ';
- To view the user table content, enter select User,host from user, you can see that the "username" user has been added, and its permissions are '% '.
- We can now use Username users to access IP in the LAN or the Internet.
MySQL -H IP address-u username-PFLUSH Privileges
Change Table Method
- If your account is not allowed to log on remotely, log in to MySQL that requires remote access to the computer where the database resides.
- Change the ' host ' entry in ' MySQL ' database from ' localhost ' to '% '
1 MySQL -u root-p2mysql> Usemysql; 3 MySQL>update user set host = '% ' where user = ' root '; 4 MySQL>select host, user from user;
Authorization Law
- Require user ' username ', use password ' password ' to connect to MySQL server from any host
1 GRANT all privileges on * * to ' username ' @ ' percent ' identified by ' password ' with GRANT OPTION; 2 FLUSH privileges;
- Require only IP for 192.168.0.1 to use username ' username ', password ' password ' to connect to MYSQ
1 GRANT all privileges on * * to ' username ' @ ' 192.168.0.1 ' identified by ' password ' with GRANT OPTION; 2 FLUSH privileges;
- Require only allow IP for 192.168.0.1 use username ' username ', password ' password ' to connect to the dbname database of the MySQL server
1 GRANT all privileges on dbname.* to ' username ' @ ' 192.168.0.1 ' identified by ' password ' with GRANT option;2FLUSH privileges;
MySQL Remote connection authorized IP