Get the App
SLTechnology News&Howtos  ›  Database  › 

What if navicat can't connect to the database?

Shulou Source: shulou.com Published: 2022-06-01 00:07:07 10月06日 Update

This article is to share with you what to do if navicat cannot connect to the database. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

When navicat connects to the database, it sometimes fails to connect. In the west, I would like to sum up the reasons and solutions.

As we all know, using Navicat to connect to a database is usually connected like this:

Problem sorting and solutions

Error one:

Cause of error:

The local IP (xxx.xxx.xxx.xxx) does not have permission to access the remote database. So the local IP (xxx.xxx.xxx.xxx) access to the remote mysql database is enabled below.

Solution:

1. First, connect remotely to the server, enter mysql-u root-p in cmd, then enter the password and enter to enter the mysql command line.

2. Enter use mysql

3. Enter select user,password,host from user; to see that there are only localhost hosts in host. We need to add xxx.xxx.xxx.xxx here as well.

4. The method of adding is as follows:

Input

Grant all privileges on *. * to root@ "xxx.xxx.xxx.xxx" identified by "password"; (xxx.xxx.xxx.xxx can also use% for all IP)

Or

GRANT ALL PRIVILEGES ON *. * TO 'root'@'xxx.xxx.xxx.xxx' IDENTIFIED BY' 123456 'WITH GRANT OPTION

This is equivalent to giving IP-xxx.xxx.xxx.xxx all permissions, including remote access.

And then enter

Flush privileges

This is equivalent to reloading mysql permissions, which must be done.

5. Enter select user,password,host from user again

You can see that there is already a new IP in host.

6. Now you can access the remote mysql database with Navicat for MySQl again, and you can open it normally.

Problem solved.

7. If you still can't connect, is MySQL Server bound to the local address, open / etc/mysql/my.cnf

Found: bind-address = 127.0.0.1

Remove the IP address binding and change it to: bind-address = 0.0.0.0

Then restart MySQL Server:/etc/init.d/mysql restart

Error 2:

ERROR 2003 (HY000): Can't connect to MySQL server on 'hostxxxxx' (10061)

Cause of error:

The mysqld database service was not started.

Solution:

Check: in the task manager of windows, or under unix/linux, ps-aux | grep mysql to take a look. Confirm that the service has been started.

Processing: starting the mysqld service

Error 3:

Firewall is on.

Solution:

The firewall needs to allow port 3306 connections.

[note: perform the above steps under the virtual machine (LINUX). The IP address xxx.xxx.xxx.xxx is the IP address to write windows or% is OK]

Thank you for reading! This is the end of the article on "what to do if navicat cannot connect to the database". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Data database input permissions errors address service reason method what to do content again password more articles questions firewall fire prevention good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Shulou Tech Info Microsoft MySQL