Can't connect to MySQL server on 'localhost' (10061)
Solution 1
You'll probably have to grant 'localhost' privileges to on the table to the user. See the 'GRANT'
syntax documentation. Here's an example (from some C source).
"GRANT ALL PRIVILEGES ON %s.* TO '%s'@'localhost' IDENTIFIED BY '%s'";
That's the most common access problem with MySQL.
Other than that, you might check that the user you have defined to create your instance has full privileges, else the user cannot grant privileges.
Also, make sure the mysql service is started.
Make sure you don't have a third party firewall or Internet security service turned on.
Beyond that, there's several pages of the MySQL forum devoted to this: http://forums.mysql.com/read.php?11,9293,9609#msg-9609
Try reading that.
Solution 2
Got this error on Windows because my mysqld.exe wasn't running.
Ran "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --install from the command line to add it to my services, ran services.msc (start -> run), found the MySQL service and started it.
Didn't have to worry about it from there on out.
Solution 3
To resolve this problem:
- go to the task manager
- select Services tab
- find MySql service
- Running
That's all.
Solution 4
I had difficulty accessing MySQL while connecting via a localhost connection on the standard port 3306, which worked fine when I installed and configured it for prior classes I had taken in MySQL and Java. I was getting errors like "error 2003" and "Cannot connect to MySql server on localhost (10061)". I tried connecting from both MySQL Workbench (5.2.35 CE) and Netbeans (7.2). I am using Windows 7 64 bit professional.
I tried typing in services.msc in the start menu search box, which opened the services dialog box to show all the services installed in windows. I scrolled down to MySQL and started this service. Subsequent attempts to connect to MySQL from MySQL WorkBench and from the command prompt succeeded.
Solution 5
English:
- press Windows + R
- write "services.msc". Then press Enter
- search for MySQL57 and right click
- click on start the service
Français :
- Appuyez sur la touche Windows + R
- Écrire "services.msc" Puis appuyez sur Entrée
- Recherchez MySQL57 et clic droit
- Cliquez sur rédémarrer
Cameron A. Ellis
Updated on July 05, 2022Comments
-
Cameron A. Ellis almost 2 years
I recently installed MySQL 5 on Windows 2003 and tried configuring an instance. Everything worked fine until I got to "Applying Security settings", at which point it gave me the above error (
Can't connect to MySQL server on 'localhost' (10061)
).I do have a port 3306 exception in my firewall for 'MySQL Server'.
-
madth3 over 11 yearsThe first paragraph of this answer is not relevant. Starting the service was already suggested by @RyanonRails
-
Ren about 11 yearsShouldn't have to resort to this. I would check and make sure that both inbound and outbound firewall rules have been added.
-
digitalextremist over 10 yearsThis is from 5 years ago. Might want to delete this and post it as a comment since so much has changed, and it seems to be incomplete/irrelevant.
-
Shailendra Madda over 8 yearsI checked it. It's running but still there is the issue:
access denied for the user root @ localhost(using password:YES)
-
Shridutt Kothari over 8 yearsit was stoped, started it and it's working now. Thanks
-
shuboy2014 almost 8 yearsits automatically stop just after i start service .
-
Vuong Tran almost 8 yearsI tried it, MySql is running but the issue is still there! Do you have any way @JapoDeveloper?
-
manish kumar about 7 yearsits automatically stop just after i start service
-
IgniteCoders over 6 years<kbd>win</kbd> >> services.msc do the trick. But MySQL Workbench cannot restart the server.
-
Adam over 6 yearsHow would MySQL Server be configured to support network connections?
-
Jane Doe almost 6 yearsit worked. May I know why and what happened? I just executed a sql and it just stopped and I wasn't able to start it using xampp after that
-
questionto42standswithUkraine about 4 yearsThe file is called hosts, not host. The path is
c:/windows/system32/drivers/etc/hosts
and I could only change it in admin mode (or you copy it somewhere, edit it there, and paste and overwrite confirming you are an admin) -
questionto42standswithUkraine about 4 yearsand this has not solved the issue, I still cannot get access to my localhost. I am also confused why the hosts file did not have any entries before I changed it, there were only the comments that helped you what to insert. After your recommended change, I still cannot connect to 127.0.0.1, using the TCP/IP connection and the 3306 port in HeidiSQL. The error stays the same.