How to set MySQL remote access MySQL is not accessible by remote machine by default, remote access can be turned on by the following configuration
On the MySQL server side:
Execute mysql command into MySQL command mode,
SQL code
- mysql> use mysql;
- mysql> Grant all on *.* to [ Email protected] '% ' identified by ' admin ' with grant option
- #这句话的意思 , the computer that allows any IP address ( % that means above) Access this mysql with the admin account and password (admin) Server
- #必须加类似这样的帐户 before you can log in remotely. root account can not be remotely logged in, only local login
mysql> use mysql;mysql> grant all on * * to [e-mail protected] '% ' identified by ' admin ' with GRANT OPTION; #这句话的意思, allow Any IP address (above the percent of this meaning) of the computer with the admin account and password (admin) to access the MySQL server# must be similar to such an account before you can log on remotely. The root account cannot be logged on remotely and can only be logged on locally
So how to access it remotely?
On another MySQL client (PC with MySQL package, Windows or Linux)
Execute command:
SQL code
- Mysql-h172.21.5.29-uadmin-padmin is ready.
- 172.21.5.29 is the IP address of MySQL server, admin admin is just the remote access account set up on 172.21.5.29
Mysql-h172.21.5.29-uadmin-padmin //172.21.5.29 is the IP address of MySQL server, admin admin is just the remote access account set up on 172.21.5.29.
Reference
mysql> use MySQL;
Mysql> Grant All on * * to [e-mail protected] '% ' identified by ' admin ' with GRANT OPTION;
#这句话的意思, allow any IP address (above the% that means) to access this MySQL Server with the admin account and password (admin)
#必须加类似这样的帐户, you can log in remotely. The root account cannot be logged on remotely and can only be logged on locally
I found a problem, if the above command you executed, you are localhost in the local, execute:
SQL code
- Mysql-hlocalhost-uadmin-padmin
The result is a failure.
It turns out that the above% does not include localhost
So you have to add such an order.
Mysql>grant all on * * to [email protected] ' localhost ' identified by ' admin ' with GRANT OPTION;