Navicat reports an error when connecting to Mysql server on my Linux system

Error code 2003, can't connect to mysql server on xxxx

Solution:

(1) #Check port opening status

# firewall-cmd --list-ports   
 
(2) #Open port 3306

# firewall-cmd --zone=public --add-port=3306/tcp --permanent 
 
(3) #Restart the firewall

#systemctl restart firewalld.service

After the port opening was solved, the following error was reported again when connecting to the database:

错误码 1130 Host xxxxx is not allowed to connect to this Mysql server

Cause of the problem: mysql does not have mysql remote access permission enabled.

Solution:

Log in to mysql on the Linux machine and modify the user table of mysql.

(1) Query the records that need to be modified

select host, user, password from user where host='localhost' and user='root';

(2) Update

update user set host='%' where host='localhost' and user='root';

(3) Refresh permissions

FLUSH PRIVILEGES;

After the above two problems are solved, reconnect to Mysql and OK.

Guess you like

Origin blog.csdn.net/hanjiangxue0912/article/details/132097658