Home > Database > Mysql Tutorial > mysql advanced (seventeen) Cannot Connect to Database Server

mysql advanced (seventeen) Cannot Connect to Database Server

黄舟
Release: 2017-02-10 11:07:26
Original
1757 people have browsed it

Cannot Connect to Database Server

Reason

Due to the inconsistency between the database user names and passwords used in different projects, one of them occurred during the execution of an earlier project. "The user specified as a definer ('root'@'localhost') does not exist" error message. After searching on the Internet, the reason was that the root user did not exist, so I changed the user name back to the previous user name. As a result, I could not connect to the database, as shown in the following figure:

Cause

1. The database service may not be started

2. The specified database connection username or password may be incorrect

3.The database connection statement may be Incorrect writing

4. Maybe the specified database does not exist in the database

5. Maybe the sql package is not imported or there is no driver

Solution

MysqlbinDirectory: C:\Program Files\MySQL\MySQL Server 5.7\bin

##mysql -u root -p

After deleting the original database instance and creating a new instance, I found that I still couldn't connect to the database, as shown below:

Still Not sure, I will continue tomorrow, my knowledge of MySQL is still too low! ...........

I eliminated the causes of the errors one by one, closed and restarted the mysql service, and found that I still couldn't log in, so I was confused.

After closing the mysql service, you can enter the workbench, but you still cannot connect to mysql. This is necessary. According to the picture below, you can know the location of the mysql configuration file my.ini:

Someone on the Internet actually suggested reinstalling it, and I couldn’t help but swear! Your sister! Is this a solution to the problem? Who would choose to reinstall this road unless absolutely necessary?

Can't connect to MySQL server on '127.0.0.1' (10061)

Check if the password is correct



How to know if the password is correct?

If the password is wrong, it will prompt that the password is incorrect

Check your hosts file

Hosts file location: C:\Windows\System32\drivers \etc



Is it a port problem? So I used telnet 127.0.0.1 3308 to test the port, and it actually prompted:

My.ini does use port 3308. Use netstat -an to check, 3308 is as follows TIME_WAIT

TimeoutStatus:

So what is the reason?

During the test in the project, it was found that it also prompted "Host 'localhost' is not allowed to connect to this MySQL server"! Going to collapse.

Start the mysql service, and the following error occurs:

Restart the computer to solve the problem.

Still unable to connect to the database!

Don’t force me, otherwise, I really have to reinstall the database!

After trying to no avail, reinstall!

Due to incomplete uninstallation during the uninstallation process, a series of problems occurred during installation. tragedy!

Mysql uninstallation tutorial: click to view

Mysql installation tutorial:

//m.sbmmt.com/

The next day...

Continue to uninstall and install, I don't believe it can't be done!

To prevent the database from being reinstalled after reinstalling the system, install it in a directory other than the C drive.

The following error occurred during the installation process:

I searched various methods on the Internet, but still could not solve the problem.

I changed my mind again and tried another version, among which I tried 5.7.10. But it is in zip format, and a series of files need to be configured after decompression. After trying to no avail, I used the lower version 5.5. 47, msi format, this is a fool-proof installation method which is more convenient. After the first installation, I tried to restore the previous database, but to no avail, and the username could not be changed. I uninstalled and installed it again. After the second time, the username could be changed normally. After testing, everything is normal!

The problem that tortured me for nearly 3 days finally ended in this way.

Feeling

The database must be backed up in time, otherwise the consequences will be disastrous!

The above is the content of MySQL Advanced (Seventeen) Cannot Connect to Database Server. For more related content, please pay attention to the PHP Chinese website (www. php.cn)!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template