Navicat 连接 MySQL :2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)

Problem: 2002 - Can't connect to server on '127.0.0.1' (36)

insert image description here

Scenes

  • Navicat 16
  • MySQL 5.7
  • Windows virtual machine
  • Mac host

preface:

Navicat is a powerful database management tool, but you may encounter the error "Can't connect to server on '127.0.0.1'" when connecting to the MySQL database during use. This article details possible causes of the issue and provides solutions to help you resolve this common connection error.

problem causes:

When you try to connect to MySQL database with Navicat, the error “Can't connect to server on '127.0.0.1'” may be caused by the following reasons:

  1. MySQL server is not running: Make sure your MySQL server is started properly. Before connecting, check that the MySQL service is running, and make sure it is listening on the default port (usually 3306).

  2. Wrong connection parameters: In Navicat connection settings, you may not configure connection parameters correctly. Please check the following items:

  • Hostname/Address: Make sure to enter the IP address or hostname of the MySQL server correctly. By default, '127.0.0.1' means localhost.
  • Port number: Make sure the port number is consistent with the port configured on the MySQL server. By default, MySQL uses port 3306.
  • Username and Password: Enter the correct database username and password. Make sure you have permission to connect to the MySQL server.
  1. Firewall settings: It could be that a firewall is blocking the connection to the MySQL server. Please make sure your firewall settings allow Navicat to connect to MySQL server. Try adding exception rules in the firewall to allow incoming and outgoing connections.

  2. MySQL Configuration Issues: Certain MySQL configurations may result in an inability to connect. Please ensure the following settings are correct in the MySQL server configuration:

  • Bind address: Make sure the MySQL server is bound to the correct IP address. If you want to allow local connections, make sure the bind address contains '127.0.0.1' or 'localhost'.
  • Authorization table settings: Check whether the permission to allow remote connections is correctly set in the MySQL authorization table.

solution:

Depending on the possible cause of the problem, here are a few common solutions to the "Can't connect to server on '127.0.0.1'" error:

  1. Check MySQL server status: Make sure the MySQL server is up and running. You can check the status of the MySQL service on the command line or in the system service manager.

  2. Check connection parameters: Double check the hostname, port number, username and password in Navicat connection settings. Make sure these parameters match your MySQL server's configuration.

  3. Configure the firewall: Make sure the firewall allows connections to the MySQL server. You can try to temporarily turn off the firewall to test, if the connection is successful, the firewall settings may be the problem. Then, add inbound and outbound rules to allow Navicat connections.

  4. Check the MySQL configuration: Look in the MySQL server's configuration file (usually my.cnf or my.ini) to make sure the bind address is set correctly and that remote connections are allowed in the grant table.

  5. Check your network connection: Make sure your network connection is working properly. Try pinging to check connectivity to the MySQL server to ensure packets are being sent and received successfully.

Summary:
"Can't connect to server on '127.0.0.1'" error is a common problem when Navicat connects to MySQL database. This error can be resolved by checking the MySQL server status, connection parameters, firewall settings, and MySQL configuration. After I checked, it was because the firewall of the virtual machine I was using was turned on, and then turned off the firewall.

Supongo que te gusta

Origin blog.csdn.net/weixin_45626288/article/details/131250857
Recomendado
Clasificación