Being given
four steps to resolve:
1. Log in to the MySQL database
2. Perform use mysql;
into the mysql database
to perform 3. After entering the update user set host = '%' where user = 'root';
statement, the error also does not matter
4. Execute FLUSH PRIVILEGES;
permissions related tables refresh the MySQL
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
If you still can't connect, delete the connection, and then create a new connection.
Provide simple script
[root@mysqld01 ~]# cat navicat.sh
#!/bin/bash
read -p "Please enter your MySQL password:" pass
mysql -uroot -p$pass << EOF
use mysql;
update user set host = '%' where user = 'root';
FLUSH PRIVILEGES;
EOF
echo "ok!"