#1. Local connection The local database cannot be connected and error code 1251 is reported.
The first step is to open the Command Line Client.
The second step is to enter the mysql password and press Enter. It is the password set when installing mysql. Just enter the password. No. Add a semicolon.
Related recommendations: "Navicat for mysql graphic tutorial"
The third step, enter ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysql Password'; press Enter. Don't miss the semicolon after it. The password for mysql is the password set when installing mysql.
The fourth step is to enter FLUSH PRIVILEGES; press Enter (don’t miss the semicolon at the end).
2. The connection to the database server within the LAN was unsuccessful.
The first step is to open the MySQL server, enter the password, and the connection is successful.
The second step is to open the database: use mysql.
Retrieve user and host fields: mysql> select user, host from user;
If there is no user with user = root and host = %, execute The following statement:
update user set host='%' where user='root';
The third step is to grant root authorization (all permissions).
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
The fourth step is to make the granted permissions effective immediately.
flush privileges;
The above is the detailed content of How to deal with failure of navicat to connect to mysql. For more information, please follow other related articles on the PHP Chinese website!