Can't connect to MySQL server on localhost (10061) Solution

Source: Internet
Author: User

First, check that the MySQL service is not started. If it is not started, start the service.

Yesterday, the MySQL 'localhost' (10061) error occurred after the server was restarted. I thought it was because too many database connections were opened and database resources were exhausted. However, after the server was restarted, the problem still occurred, so you can find a solution on the Internet. It is roughly as follows:

Solution:
Step 1
Delete my. ini under c: \ windows \
Step 2
Open c: \ mysql \ bin \ winmysqladmin.exe and enter the user name and password.
Step 3: Input mysqld-nt-remove in dos to delete the service
Enter mysqld-nt-install
Step 4: enter that mysql is started successfully.
Other methods for reference:
1. Check whether the localhost In the hosts file points to 127.0.0.1.
2. If the mysql service is not started, you can run net start mysql.
3. Some related commands:
Mysqld-nt -- install # Start Mysql
Mysql # Run Mysql
Mysql-h ipAddress-u username-p
Or: directly go to the binpoint mysqld.exeor mysqld-nt.exe to check whether the process is running normally. If not, go to the control panel and start it in the service to check what is wrong. If not, delete mysql in the Add/delete operation and reinstall mysql. Generally, the problem can be solved. You can back up DATA before installation.
Error: Can't connect to MySQL server on 'localhost' (10061)
Errno.: 2003
Error No.: 2003
Problem Analysis:
Unable to connect to the MySQL server, possible situation:
1. the MySQL service is not started. It is generally caused by the failure of MySQL to start in case of exceptions, such as no available disk space or incorrect basedir path setting of MySQL in my. ini;
2. the MySQL server cannot be connected due to insufficient resources.
Solution:
1. If you are a VM user (purchased space), contact the Space Provider to check whether MySQL is started normally and confirm the MySQL configuration information (whether it is localhost );
2. If you are an independent host user (with host management permissions), perform the following steps:
1) check whether there is any available space in the disk space and try to keep enough disk space available.
2) check whether the parameter settings of basedir (MySQL installation address) and datadir (data directory storage address) in my. ini are correct, and then restart the MySQL service.
Another way is to patch the server windows.
Microsoft released the TCP/IP update Patch (KB967723) on September 23, September 9. If the server enables automatic updates or the software is automatically updated to download and update the patch, this problem may occur.
Some may ask why the patch on the 9th has not been detected yet?
As we all know, the server does not restart every day. Some servers may restart once a month or a year or a half. Some may restart the server after January 1, September 9, so the patch takes effect (I personally think so ).
Patch uninstall method: log on to the server and go to control panel-add and delete programs-(check "show updates" at the top ")
You can see the updated KB967723 patch in it, and uninstall it just like you want to uninstall common software. The uninstallation will prompt you. If the uninstallation may cause program running errors, it doesn't matter. Select "yes ", continue Uninstall.
After the uninstall is complete, the program server is running normally!
As to what vulnerabilities the patch patches fix and whether there will be server security risks after uninstalling the patch, this is the only way to solve this problem if MYSQL runs normally.

In other cases, you can solve this problem.
Discuz! Info: Can not connect to MySQL server

Time: pm
Script:/bbs/index. php

Error: Can't connect to MySQL server on 'localhost' (10061)
Errno.: 2003

Similar error report has beed dispatched to administrator before.
Under normal circumstances, the reasons are as follows:
The website forum traffic is too large, and the database connection exceeds the maximum number of connections. The MYSQL Database Service has stopped.

Solution (for WIN system ):
1. First, find the MYSQL service in the System Service and start the MYSQL service.
2. Go to the MYSQL installation directory and find the MY. INI file. Open MY. INI to find max_connections and change the connection count to 1000. Restart IIS and MYSQL services.

Windows
Enter the following command line:
> Cd E: \ mysql \ bin
> Mysqladmin-u root password your password
> Mysql-u root-p
Enter password: Your password
You can

,,,,,,,,,,,,,,,,,
Find the root cause, and try again here:

The root cause of this problem is: Because the password is set for the root of mysql, rather than the password is blank when the initial installation is good, use

Mysqladmin version cannot work like this. It must be like this: mysqladmin-uroot-p version. Press enter and follow the prompts to enter

Run the command with the root password.

The first method is actually a solution without knowing the root password. In this way, you can simply start mysql without a password.

And modify the root password to solve the problem of forgetting the root password.


Enter the "mysqladmin-u root password your password" command to modify the password of the root user.

If you are prompted to enter the original password and the execution is successful, the original password is blank. After that, you can use the modified password to log on successfully.



................................. How to change the password?
First of all, we need to declare that, in most cases, modifying MySQL requires the root permission in mysql, so generally users cannot change the password.

, Unless the Administrator is requested.

Method 1
Phpmyadmin is the simplest. Modify the user table of the mysql database,
But don't forget to use the PASSWORD function.
Method 2
Use mysqladmin, which is a special case stated above.
Mysqladmin-u root-p password mypasswd
After entering this command, you need to enter the original root password, and then the root password will be changed to mypasswd.
Change the root in the command to your username, and you can change your password.
Of course, if your mysqladmin cannot connect to mysql server, or you cannot execute mysqladmin,
This method is invalid.
In addition, mysqladmin cannot clear the password.
The following methods are used at the mysql prompt and must have the root permission of mysql:

Method 3
Mysql> insert into mysql. user (Host, User, Password)
VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit '));
Mysql> FLUSH PRIVILEGES
Specifically, this is adding a user with the username jeffrey and password biscuit.
I wrote this example in mysql Chinese reference manual.
Be sure to use the PASSWORD function, and then use flush privileges.
Method 4
Similar to method Sany, but the REPLACE statement is used.
Mysql> replace into mysql. user (Host, User, Password)
VALUES ('%', 'Jeffrey ', PASSWORD ('biscuit '));
Mysql> FLUSH PRIVILEGES
Method 5
Use the set password statement,
Mysql> set password for "= PASSWORD ('biscuit ');
You must also use the PASSWORD () function,
However, you do not need to use flush privileges.
Method 6
Use the GRANT... identified by statement
Mysql> grant usage on *. * TO "identified by 'biscuit ';
Here, the PASSWORD () function is unnecessary and does not need to be flush privileges.
Note: PASSWORD () [not] implements PASSWORD encryption in the same way as Unix PASSWORD encryption.
How to fix MySQL password loss
If MySQL is running, killall-TERM mysqld is first killed.
Start MySQL: bin/safe_mysqld -- skip-grant-tables &
You can access MySQL without a password.
Then
> Use mysql
> Update user set password = password ("new_pass") where user = "root ";
> Flush privileges;
Kill MySQL again and start MySQL in a normal way.

Linux
Method 1:
#/Etc/init. d/mysql stop
# Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
# Mysql-u root mysql
Mysql> UPDATE user SET Password = PASSWORD ('newpassword') where USER = 'root ';
Mysql> flush privileges;
Mysql> quit

#/Etc/init. d/mysql restart
# Mysql-uroot-p
Enter password: <Enter the new password newpassword>

Mysql>


Method 2:
Directly use the username and password provided in the [client] section of the/etc/mysql/debian. cnf file:
# Mysql-udebian-sys-maint-p
Enter password: <Enter the password in the [client] section>
Mysql> UPDATE user SET Password = PASSWORD ('newpassword') where USER = 'root ';
Mysql> flush privileges;
Mysql> quit

# Mysql-uroot-p
Enter password: <Enter the new password newpassword>

Mysql>


Method 3:

# Mysql-uroot-p
Enter password: <Enter the password provided in [client] in the/etc/mysql/debian. cnf File>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.