Home  >  Article  >  Database  >  navicat cannot connect to the database

navicat cannot connect to the database

angryTom
angryTomOriginal
2019-08-10 09:10:1333076browse

navicat cannot connect to the database

When navicat connects to the database, sometimes it fails to connect. Xi Mian will summarize for everyone the reasons and solutions.

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

navicat cannot connect to the database

Problem organization and solutions

Error one:

navicat cannot connect to the database

Error reason:

Local IP ( xxx.xxx.xxx.xxx) does not have permission to access the remote database. So the following enables the local IP (xxx.xxx.xxx.xxx) access rights to the remote mysql database.

Solution:

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

navicat cannot connect to the database

2. Enter use mysql;

navicat cannot connect to the database

3. Enter select user,password,host from user; you can see There is only the localhost host in the host. We need to add xxx.xxx.xxx.xxx here too.

navicat cannot connect to the database

4. Add as follows:

Enter

grant all privileges on *.* to root@”xxx. xxx.xxx.xxx" identified by "password"; (xxx.xxx.xxx.xxx can also use % to represent all IPs)

 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 are granted, including remote access permissions.

Then enter

flush privileges;

This is equivalent to reloading mysql permissions, this step is required.

navicat cannot connect to the database

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

You can see that there is a newly added IP in the host.

navicat cannot connect to the database

6. Now use Navicat for MySQl to access the remote mysql database again, and it can be opened normally.

problem solved.

7. If you still can’t connect, is MySQL Server bound to a local address? Open /etc/mysql/my.cnf,

Find: 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)

Error reason:

mysqld database service has not been started.

Solution:

Check: Use ps -aux | grep mysql in Windows Task Manager or unix/linux. Confirm that the service has started.

Processing: Start the mysqld service

Error three:

The firewall is enabled

Solution:

The firewall needs to allow port 3306 to connect.

Note: The above steps are performed under a virtual machine (LINUX). The IP address xxx.xxx.xxx.xxx is the IP address of windows or %.

The above is the detailed content of navicat cannot connect to the database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Where to download navicatNext article:Where to download navicat