Tag Archives: is not allowed to connect to this MYSQL server

Remote connection to MySQL database error: is not allowed to connect to this MYSQL server solution

1. Change the table method.

It may be that your account does not allow remote login, only localhost. At this time, as long as you are on the localhost computer, after logging in to MySQL, change the “host” item in the “user” table in the “mysql” database, and change the name from “localhost” to “%”

mysql - u root - p

mysql > use mysql;

mysql > update  user  set host =  ' % '  where  user  =  ' root ' ;

mysql > select host, user  from  user ;

 

 

Note: Personally feel that it is not suitable!

 

[Error content]: SQL Error (2013): Lost connection to MySQL server at’waiting for initial communication packet’, system error: 0

[Error generation process]: Appears when connecting to MySQL.

[Solution]: Open my.ini, find the [mysqld] item, add a sentence after it: skip-name-resolve, save, and restart the mysql service~

 

The above is the full text introduction to solve MySQL Error (2013): Lost connection to MySQL server at waiting for initial communication packet, I hope it will be helpful for you to learn and use the database.

 

2. Authorization law.

 

1) For example, if you want myuser to use mypassword to connect to the mysql server from any host.

GRANT  ALL  PRIVILEGES  ON  * . *  TO  ' myuser ' @ ' % ' IDENTIFIED BY  ' mypassword '  WITH  GRANT  OPTION ;

FLUSH    PRIVILEGES ;

 

2) If you want to allow the user myuser to connect to the mysql server from the host whose ip is 192.168.1.6, and use mypassword as the password

GRANT  ALL  PRIVILEGES  ON  * . *  TO  ' myuser ' @ ' 192.168.1.3 ' IDENTIFIED BY  ' mypassword '  WITH  GRANT  OPTION ;

FLUSH    PRIVILEGES ;

 

3) If you want to allow the user myuser to connect to the dk database of the mysql server from the host whose ip is 192.168.1.6, and use mypassword as the password

GRANT  ALL  PRIVILEGES  ON dk. *  TO  ' myuser ' @ ' 192.168.1.3 ' IDENTIFIED BY  ' mypassword '  WITH  GRANT  OPTION ;

FLUSH    PRIVILEGES ;

 

 

The first method I used 1), and finally execute a statement mysql>FLUSH RIVILEGES to make the modification effective.

There is another method, but I haven’t tried it personally, I can find it on csdn.net, you can take a look.

Run on the machine where mysql is installed:

1. d: / mysql / bin /> mysql    - h localhost    - u root   // This should be able to enter the MySQL server

2. mysql > GRANT    ALL    PRIVILEGES    ON    * . *    TO    ' root ' @ ' % '    WITH    GRANT    OPTION   // Give any host access to data

3. mysql > FLUSH    PRIVILEGES   //The modification takes effect

4. mysql > EXIT   // Exit the MySQL server

 

In this way, you can log in as root on any other host!