Enable MySQL remote access permission to allow remote connection to bitsCN.com
1. log on to the mysql database
Mysql-u root-p
View user table
Mysql> use mysql;
Database changed
Mysql> select host, user, password from user;
+ -------------- + ------ + --------------------------------------------- +
| Host | user | password |
+ -------------- + ------ + --------------------------------------------- +
| Localhost | root | * A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | * A731AEBFB621E354CD41BAF207D884A609E81F5E |
+ -------------- + ------ + --------------------------------------------- +
2 rows in set (0.00 sec)
You can see the created root user in the user table. The host field indicates the host to log on to. The value can be an IP address or a host name,
(1) If you want to log on with a local IP address, you can change the Host value to your own Ip address.
2. implement remote connection (authorization)
Changing the value of the host field to % indicates that you can log on to the mysql server as a root user on any client machine. we recommend that you set the value to % during development.
Update user set host = '%' where user = 'root ';
Change the permission to all privileges.
Mysql> use mysql;
Database changed
Mysql> grant all privileges on *. * to root @ '%' identified by "root ";
Query OK, 0 rows affected (0.00 sec)
Mysql> select host, user, password from user;
+ -------------- + ------ + --------------------------------------------- +
| Host | user | password |
+ -------------- + ------ + --------------------------------------------- +
| Localhost | root | * A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | * A731AEBFB621E354CD41BAF207D884A609E81F5E |
| % | Root | * A731AEBFB621E354CD41BAF207D884A609E81F5E |
+ -------------- + ------ + --------------------------------------------- +
3 rows in set (0.00 sec)
In this way, the machine can remotely access MySql on the machine with the username root password root.
3. remote connection (table change)
Use mysql;
Update user set host = '%' where user = 'root ';
In this way, you can access Mysql through the root user at the remote end.
BitsCN.com