Navicat connects to mysql and reports error 2003 (10060)

For Navicat connecting to the database mysql, an error 2003 (10060) occurs, as shown below
insert image description here

After querying and summarizing the above problems, there are three main solutions:

1. The MySQL service is not started. This is the most common cause of the problem.

WIN+R, enter services.msc to open the service manager, find mysql,
insert image description here
insert image description here
if it shows that mysql is disabled, you can right-click to start the service, and then retest the connection in Navicat

2. MySQL does not have remote permissions

1) View permissions
Check the relevant information of the current root user, whether there is remote permission, as shown in the figure below, if the host of the root user is localhost, it means that only local access is supported, and remote access is not allowed. Need to change to %

//登录mysql
mysql -u root -p;
//选择mysql数据库
use mysql;
//查看user表
select host, user, authentication_string, plugin from user; 

insert image description here
2) Modify permissions

If it is a version before mysql8.0

mysql -u root -p #进入MySQL数据库后进行一下操作。
mysql> use mysql;
mysql> grant all privilegs on *.* to 'root'@'%' identified by 'root用户密码' with grant option;
mysql> flush privileges;

If it is mysql8.0 or above

mysql> update user set host = '%' where user = 'root';
mysql> flush privileges;

3. Firewall interception

Open Windows Settings, select Update & Security
insert image description here
Select Windows Security Center, then Firewall and Network Protection
insert image description here
Open Advanced Settings
insert image description here

Inbound rules on the left, then click New Rule on the right, select the port, and then click Next.
insert image description here
Specific local port, fill in 3306, other defaults are not modified, click Next. Default
insert image description here
is not modified, click Next.
insert image description here
Default is not modified, click Next
insert image description here
Fill in the name and description, choose the name yourself, and click Finish.
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44696740/article/details/129003523