About MySQL exception handling Can ' t connect to MySQL server on localhost (10061) workaround

Source: Internet
Author: User

First check that the MySQL service does not start if it does not start, then start the service.

Yesterday, after restarting the server after the MySQL ' localhost ' (10061) error, began to think that because the database link open too much, the database resource exhaustion, but after restarting the server, there are still problems, so find a solution on the Internet. Broadly as follows:

Workaround:
The first step
Remove the My.ini below c:\windows\
Step Two
Open C:\mysql\bin\winmysqladmin.exe Enter user name and password
Step three Enter Mysqld-nt-remove Delete service under DOS
In the next input Mysqld-nt-install
Fourth step enter MySQL to start successfully.
Other methods to refer to:
1. See if localhost is pointing to 127.0.0.1 in the Hosts file.
2. If the MySQL service is not started, you can run net start MySQL.
3. Some related commands:
Mysqld-nt--install #启动Mysql
MySQL #运行Mysql
Mysql-h Ipaddress-u Username-p
Or: Go directly to the bin point Mysqld.exe or Mysqld-nt.exe, see if its process can run normally, if not, then go to the Control Panel, service to start it, see what is wrong. If not, you can delete MySQL from the add-in, and then reinstall MySQL, which will generally solve the problem, and backup the data before installing.
Error:can ' t connect to MySQL server on ' localhost ' (10061)
Errno.: 2003
Error Number: 2003
Problem Analysis:
Unable to connect to MySQL server, the possible scenario is:
1, the MySQL service does not start, generally in the case of abnormal MySQL can not start, such as no disk space available, My.ini mysql basedir path settings error, etc.;
2, MySQL server resources are tight, resulting in the inability to connect.
Workaround:
1. If you are a virtual host user (space purchased), contact the space provider to check if MySQL is starting normally, and confirm the MySQL configuration information (whether localhost);
2. If you are a standalone host user (with administrative host permissions), follow these steps to check:
1) Check the disk space for any remaining free space and try to keep enough disk space available.
2) Check the My.ini basedir (MySQL installation address) and DataDir (data directory storage address) and other parameters are set correctly, and then restart the next MySQL service.
Another way is to put the Windows patch on the server.
Microsoft September 9 released the TCP/IP update patch (KB967723), this issue occurs if the server turns on Automatic Updates or if the patch is updated with an automatic Update software download.
One might ask, why did the patch 9th appear, until now to discover the problem?
As we all know, the server is not restarted every day, some servers may be one months or a year reboot, some may restart the server after September 9, so the patch takes effect (I personally think).
Patch Uninstall Method: Log in to the server, enter the control Panel---Add and Remove Programs--(tick "show Updates" above)
In the inside can see the update KB967723 this patch, and then just want to uninstall the normal software like uninstall, uninstall will prompt you, if uninstall may cause the program to run an error, do not matter, select "Yes", continue to uninstall.
Uninstall complete after the program server, everything is OK!
As for the patch to fix what vulnerability, after uninstalling whether there will be a server security risks, this is not to say, to MySQL normal operation, the temporary solution is the only way.

There's a situation where you can solve this.
discuz! Info:can not connect to MySQL server

TIME:2007-11-13 6:25pm
Script:/bbs/index.php

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

Similar Error Report have beed dispatched to administrator before.
Under normal circumstances, the following are the reasons:
Site forum access is too large, the database connection exceeds the maximum number of connections. The MySQL database service stopped.

Workaround (for win system):
1, first find the MySQL service inside the system service and start the MySQL service.
2, to the MySQL installation directory to find the My.ini file, open My.ini find max_connections Modify the number of connections to 1000 restart IIS with the MySQL service.

Under Window
At the command line, enter:
>CD E:\mysql\bin
>mysqladmin-u Root Password your password
>mysql-u root-p
Enter Password: your password
Then you can

、、、、、、、、、、、、、、、、、
Find the root cause and cool it here:

The root cause of this problem is that because the password is set to the root of MySQL, instead of the password that was initially installed, use

Mysqladmin version like this, must be like this: Mysqladmin-uroot-p version, enter after you follow the prompts required

Root password to run the command successfully.

The first method is actually a solution without knowing the root password, so start without password to go to MySQL

Inside and the root password is modified to resolve the problem of forgetting the root password.


The command "mysqladmin-u root password your password" function is to modify the root user's password, this command can be

Prompt to enter the original password and successfully executed, also indicates that the original password is empty. After that, use the modified password to successfully log in.



。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 How do I change my password?
First of all, to declare a point, in most cases, to modify MySQL is required to have root permissions in MySQL, so the general user cannot change the password

, unless the administrator is requested.

Method One
Using phpMyAdmin, this is the simplest, modify the MySQL library's user table,
But don't forget to use the password function.
Method Two
Using Mysqladmin, this is a special case of the preceding declaration.
Mysqladmin-u root-p Password mypasswd
After entering this command, you need to enter the root's original password, then the root password will be changed to MYPASSWD.
Change the root of the command to your username, and you can change your own password.
Of course if your mysqladmin is not connected to MySQL server, or you have no way to execute mysqladmin,
Then this method is ineffective.
And mysqladmin can't erase the password.
The following methods are used at the MySQL prompt and must have root privileges for MySQL:

Method Three
Mysql> INSERT into Mysql.user (Host,user,password)
VALUES ('% ', ' Jeffrey ', PASSWORD (' biscuit '));
Mysql> FLUSH Privileges
Specifically, this is the addition of a user named Jeffrey, with a password of biscuit.
There is this example in the MySQL Chinese reference manual, so I wrote it out.
Note that you want to use the password function, and then you also use the flush privileges.
Method Four
As with method Three, just use the Replace statement
Mysql> REPLACE into Mysql.user (Host,user,password)
VALUES ('% ', ' Jeffrey ', PASSWORD (' biscuit '));
Mysql> FLUSH Privileges
Method Five
Using the Set Password statement,
Mysql> SET PASSWORD for "= PASSWORD (' biscuit ');
The password () function must also be used,
However, you do not need to use flush privileges.
Method Six
Use Grant ... Identified by statement
Mysql> GRANT USAGE on *. * to "identified by ' biscuit ';
Here the password () function is unnecessary and does not require the use of flush privileges.
Note: PASSWORD () [NOT] Execute password encryption in the same way that the UNIX password is encrypted.
MySQL Forgot Password Solution
If MySQL is running, first kill it: Killall-term mysqld.
Start Mysql:bin/safe_mysqld--skip-grant-tables &
You can go to MySQL without a password.
Then there is
>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 under
Method One:
#/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 newly set password newpassword>

Mysql>


Method Two:
Use the user name and password provided directly in the [client] section of the/etc/mysql/debian.cnf file:
# mysql-udebian-sys-maint-p
Enter Password: < Enter the password for 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 newly set password newpassword>

Mysql>


Method Three:

# mysql-uroot-p
Enter Password: < Enter the password provided in the [Client] section of the/etc/mysql/debian.cnf file >

About MySQL exception handling Can ' t connect to MySQL server on localhost (10061) workaround

Related Article

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.