Tag Archives: Failed to Connect to MySQL

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!

MySQL Workbench Failed to Connect to MySQL at 127.0.0.1:3306 with user root Bad handshake

Msi

installation package: mysql-workbench-community-8.0.18-winx64. Msi

version no. : MySQL Workbench 8.0 CE

connection tip:

tried

1. Neither localhost nor ::1

2. Query whether host exists under user, -> Invalid


3. Add
bind-address = 127.0.0.1


” under [mysqld] in my. Navicat and hedisql can both connect

finally found a solution in bug-75745: due to the high version of the incompatible, download version 6.3.10 at the workbench download address to install

why do you want to use MySQL Workbench?Because you need to switch databases in multiple environments in your work, so after using heidisql(GPL open source) and navicat(charged), I tried a wave of MySQL Workbench(Community GPL open source) and found that there are multiple tabs to switch multiple environment databases, which can be used. If you are used to heidisql and navicat, you can use them without changing