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!
Read More:
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server
- host ‘‘ is not allowed to connect to this mysql server Connect MYSQL Error
- [Solved] Error: ER_HOST_NOT_PRIVILEGED: Host ‘x.x.x.x‘ is not allowed to connect to this MySQL server
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- IDEA maven Config MYSQL Connection Error: Could not create connection to database server.
- Docker: How to Solve MYSQL8 & Navicat remote connection error
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- Ubuntu ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (111)
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- [Solved] com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- MYSQL Enter password:ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘
- [Solved] mysql 2003 remote access failed mysql8 configure remote access
- Using Mybatis to connect to the database error: Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver···
- [Solved] Error Code: 2013. Lost connection to MySQL server during query
- C# Connect MYSQL Error: MySql.Data.MySqlClient.MySqlException:“SSL Connection error.”
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe