A friend may encounter a 10061 or 1045 error or 2003-Can't connect to mysqlon 192 when using Navicatformysql to remotely connect to the mySql database. 168.1.2 '(10061), because MySQL does not allow remote connection.
A friend may encounter a 10061, 1045 error or 2003-Can't connect to mysql on '100. 168.1.2 '(10061), because MySQL does not allow remote connection.
The simplest way is
MySQL Remote Configuration
| The Code is as follows: |
|
|
Grant all privileges on *. * TO root @ '%' identified by 'your paaa '; % indicates that multiple machines exist.
|
Open Port 3306, set exceptions for the firewall, and release port 3306.
But you must have the root permission,
You can also modify the settings as follows:
1: Find the my. ini file in the MySQL folder on the server. Modify bind-address = 127.0.0.1 to bind-address = 0.0.0.0 (this item is not found in my. ini of MySQL 5)
2: restart the MySQL service.
Test connection status:
"1045-denied for user root @ IT (using password: NO)" will appear if you do not have the permission to access all machines added to the remote login user, indicating that you need to add permissions;
Add the following command:
| The Code is as follows: |
|
|
1) grant all on *. * to username @ "%" identified by "password ";
2) flush privileges; |
After completing the preceding steps, you can remotely access MySQL.
If the problem persists, we can enable the MySQL remote access permission to allow remote connection.
1. log on to mysql
| The Code is as follows: |
|
|
Mysql-u root-p |
View user table
| The Code is as follows: |
|
Mysql> use mysql;
Database changed
Mysql> 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.
| The Code is as follows: |
|
|
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 user name root.
3. remote connection (Table change)
| The Code is as follows: |
|
|
Use mysql;
Update user set host = '%' where user = 'root '; |
In this way, you can access Mysql through the root user at the remote end.