75

I installed MySQL using mysql-installer-5.5.20.0.msi on Windows 7. From the cmd window, I run "mysqlshow -u root -p". It asked for a password, then returned this error: "Can't connect to MySQL server on 'localhost' (10061)" This is a bad indication of partially failed/successful installation.

After reading the page, http://dev.mysql.com/doc/refman/5.5/en/windows-troubleshooting.html, it told me to find an error log (.err) in C:\Program Files\MySQL\MySQL Server 5.5\data. The directory exists but there is no log file.

I have a feeling this is related to the tight security of Windows 7, especially when installing a Unix based software. And yes, I am the Administrator on my PC.

Any help or suggestions is appreciated. And I can return a favor by answering Java and SQL query questions.

The Original Android
  • 6,147
  • 3
  • 26
  • 31
  • It more sounds like you supply an invalid username/password when trying to connect. – Cyclonecode Jun 05 '12 at 06:33
  • well, root as username is supplied by the installation so that should be valid. And I did not set a password for root, at least not yet, for ease of use for now. – The Original Android Jun 05 '12 at 06:43
  • 2
    Your are sure that the MySQL server process is actually running? – glglgl Jun 05 '12 at 08:17
  • Have you setup your server to run on default port 3306? If so try to telnet to that port. Also, if you have a firewall running make sure you allow connections on port 3306. Of course you should also check so that your mysql daemon is running using the taskmanager or similar. – Cyclonecode Jun 05 '12 at 13:06
  • 4
    From the documentation: `(10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server`. – Cyclonecode Jun 05 '12 at 13:08
  • @glglgl, good question. I tried to start the server by "mysqld --console", and got the same error message. – The Original Android Jun 06 '12 at 06:43
  • So...I suspect the simple mysqlshow requires the server to run. And for now, I could not even start the server. – The Original Android Jun 06 '12 at 06:52
  • @Krister, I did not change the default port 3306 during installation. I did try to telnet to that port, as you said. And it seems fine since I do not see any error messages. I intentionally do not use firewall on my PC. – The Original Android Jun 06 '12 at 06:56
  • When you connect to port 3306 through telnet, do you get a any output indicating that the mysql server is running? You should also check your event log. – Cyclonecode Jun 07 '12 at 06:28
  • @Krister, After I telnet port 3306, I run mysqld --console, and getting same error. – The Original Android Jun 07 '12 at 22:14
  • I never got the my.ini file at the usual directory C:\Program Files\MySQL\MySQL Server 5.5. And I do not get an error file at the usual directory C:\Program Files\MySQL\MySQL Server 5.5\data. I start realizing that I could not create a file in these directories, meaning I do not have access permission in these directories. I think I must change access permissions for MySQL to work properly. I may have to post a NEW question under Windows and Windows 7. Does that sound sensible? – The Original Android Jun 07 '12 at 22:18
  • 4
    You should try asking questions of this type in http://serverfault.com/faq or perhaps http://superuser.com/faq – Cyclonecode Jun 07 '12 at 22:23

34 Answers34

92

Please Try the following steps:

  1. c:\mysql\bin>mysqld --install
  2. c:\mysql\bin>mysqld --initialize

then press "Windows key + R" write "services.msc", run as admin

start MySQL service.

K. Yen
  • 193
  • 2
  • 14
maheshDeshmukh
  • 929
  • 1
  • 6
  • 2
  • 1
    I had to first run 'msconfig' and then your answer worked for me – Vyshnav Ramesh Thrissur Nov 27 '18 at 09:51
  • 9
    Am on version 8.0.1, Just starting `MySQL80` from services solved the issue. I haven't follow the steps 1 & 2. – Mathew John Jun 05 '19 at 16:37
  • 1
    Great, it's good. Just to mention that I had to run these commands as admin, and it was solved. Thank you. – sk001 Mar 29 '21 at 23:20
  • This solution worked for me. MySQL `Workbench 8.0 version` – Ender May 20 '22 at 16:41
  • For me "mysqld --install" stopped running because it said the service was already there or something like that. So I went into MySQL WorkBench Manage Connections and deleted that one. Then I could run "mysqld --install". Also I ran the windows CMD shell as administrator. But it is running for a while. I don't know if it will finish. – John Foll Jun 06 '22 at 21:50
65

I also faced the same issue and resolved it by below setups:

  1. Check the MYSQL service in the windows service. If it is there and not running then start it. It will solve your problem.

    You can find the services window by navigating to windows Start menu and typing 'services' in the search bar. Select the 'Services' option with the cogs next to it (not the executable file) and the below window will appear. Scroll down to find 'MySql (version)'. When you select MySql you should see an option in the left pane that says 'Start the service'. Click this and a dialogue should appear to indicate Windows is attempting to start the service. Once started the left pane will now give you the option to stop, pause and restart the service and you will now be able to connect to your MySql from the windows cmd line.

enter image description here

  1. If MYSQL service is not present in windows service then follow below setups.

    a. Open cmd as administrator.

    b. cd to C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin

    c. Run the command: C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin>mysqld.exe --install

    d. Check the MySql in the windows service, And if it is not running, Start it by clicking on the service.

    e. If your using XAMMP . Start MySQL at the XAMMP control Panel.


Burkely91
  • 902
  • 9
  • 28
Programming-Lover
  • 1,177
  • 10
  • 14
33

this issue is very to solve by windows server users

  1. go to this path C:\Program Files\MySQL\MySQL Server 5.1\bin

  2. run this tool "MySQLInstanceConfig.exe"

and config the instatnce again and problem solved

shay lami
  • 394
  • 3
  • 2
13

The simple solution that worked for me is: change localhost to 127.0.0.1 in your database.yml or in your script if writing one.

doubleDown
  • 8,048
  • 1
  • 32
  • 48
Keramat
  • 131
  • 1
  • 3
  • 1
    according to @Vasekdvor at http://stackoverflow.com/a/12600684/267542 it might be something to do with an ipv6 mixup. – Segfault Oct 29 '12 at 00:52
11

Here, you need to make sure that the MySQL service is running is Windows. It might be possible that your MySQL service is not running cuurrently.

  1. Open Services window by pressing Windows+R and entering services.msc
  2. Find out MySQL right click and select start.

It works.

7bStan
  • 160
  • 1
  • 4
  • 13
10

I had this error - stupid mistake was, I was using -p3307 to specify port, whereas I should have used -P3307, i.e. capital P. Small 'p' is for password arg :)

Frederik Struck-Schøning
  • 12,981
  • 8
  • 59
  • 68
8

In Windows 7

  1. press Windows+R it opens Run
  2. Enter services.msc
  3. Find out mysql right click and start
  4. if mysql was not found
    1. Run cmd as administrator
    2. goto C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin directory(to go back use cd..) and type mysqld.exe --install
  5. follow step 3

That's all

barbsan
  • 3,418
  • 11
  • 21
  • 28
nikhil
  • 81
  • 1
  • 1
7

I solved this by adding the following arguments to the command line string:

mysql --user username --password password --host localhost --port 3306 databasename < "system path to .sql file"

Without the --host and --port arguments, especially if you change the port to let's say 3307, which is a non default value, will cause this error.

barbsan
  • 3,418
  • 11
  • 21
  • 28
Charles Robertson
  • 1,760
  • 16
  • 21
  • 1
    This is the only answer that helped me. In my case the mysqld service was running fine but I had to pass -host localhost in command line to connect – bluelurker Mar 09 '19 at 15:14
  • Same goes, I had tried every other answer I came across. This is what did it for me. +1 – drew181 Apr 09 '21 at 10:08
6

I got this error in command prompt when I tried to open MySQL from cmd "mysql -u root -p"
Can't connect to MySQL server on 'localhost:3306' (10061)
It was because I changed my port during the installation of MySQL community server as I had XAMPP server installed and running as well which was not allowing me to use the port 3306. So basically I had 2 MySQL servers installed in my system.

  1. MySQL community server.
  2. XAMPP server.

If anyone had this same issue this is how I fixed it. Step 1: Reconfigure MySQL server to port 3306 Step 2: Reconfigure XAMPP to use a different port other than 3306

Note: Stop the XAMPP server before following the steps.

Step 1: Reconfigure MySQL server to port 3306

  1. Click Start and open MySql installer - community
  2. Click on reconfigure button in front of MySql server
  3. Type 3306 in port. Execute and complete the installation. enter image description here

Step 2: Reconfigure XAMPP to use a different port other than 3306

  1. Open XAMPP and change the port other than 3306 in two files
    my.ini under MySQL
    and php.ini under Apache enter image description here

Now everything seems to be working fine for me. I was able to get into MySQL community server from cmd and I can use XAMPP server as well.

Dharman
  • 30,962
  • 25
  • 85
  • 135
mrsagar105
  • 176
  • 2
  • 6
5

I have Windows 8.1 and I too had this problem. My teacher told me it was probably because my MySQL server had stopped running. She told me to go into the Computer Management utility (right click the lower-most left hand corner of the screen on Windows 8.1 to access Computer Management). Then under Services and Applications, open up the Services and find MySQL. You should be able to right-click on MySQL and restart it.

Avilio
  • 581
  • 6
  • 5
4
  1. In Start Menu, search for "mysql". Among the results, you should see the "MySQL Installer - Community". Run it.

  2. MySQL Installer window will show up as shown below. Find "MySQL Server" under Product and click on "Reconfigure" link.

  3. The MySQL Installer will show up (same one you used for the first MySQL Server installation). Go through all the steps.

  4. After the MySQL Installer was finished, I started the MySQL service again. This time, the "Startup Message Log" on The MySQL Notifier was showing that the server started successfully:

https://www.howtosolutions.net/2017/08/fixing-mysql-10061-error-after-migration-of-database-files/

nishith kumar
  • 981
  • 7
  • 20
3

This is the easiest solution and worked for me.

  • Go to where you downloaded "mysql-installer-web-community-8.0.19.0.msi", file for installing mysql.
  • Run this by double clicking on it. (No need to uninstall anything)
  • Click on "reconfigure" beside the MySql server.
  • Agree everything which comes in middle, provide password for root where asked.
  • Finish. That's it you're good to go.
  • 1
    this will definitely work, if any of the above solutions doesn't work – Rama Krishna Reddy May 19 '20 at 06:12
  • After hunting for much longer than expected this was the solution for me. Rerunning the installer and stepping through the configuration wizard I did not see many of these steps during first installation. Followed above steps and reran Workbench - server is up and running. – Frank Dec 15 '20 at 17:11
2

For the 5.7 version, I had the same problem and a simple fix did the trick. As Installed the workbench 5.7 there was another "software" of sorts called the "MySQL Installer Community". I ran this and ran the "Reconfigure" for the MySQL server. It took about a minute and the problem was no longer there.

Hope it works!.(Keep in mind i was using the 5.7 version)

user0221441
  • 368
  • 4
  • 11
1

Just turn off the firewall and remove the instance configuration. Add a new instance for the server.![Disable Firewall][1] Give he port number correctly as 3306 as default

Prabhakar
  • 11
  • 1
1

Solution 1:

For 32bit: Run "mysql.exe" from: C:\Program Files\MySQL\MySQL Server 5.6\bin

For 64bit: Run "MySQLInstanceConfig.exe" from: C:\Program Files\MySQL\MySQL Server 5.6\bin

Solution 2:

The error (2002) Can't connect to ... normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.

The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server.

Source: http://dev.mysql.com/doc/refman/5.6/en/starting-server.html Visit it for more information.

1

For anyone who have the same problem of "Can't connect to MySQL server on 'localhost' (10061) " or "Can't connect to MySQL server on '127.0.0.1' (10061) ". You can install "MySQL Installer" and this is the link http://dev.mysql.com/downloads/windows/installer/5.6.html and this is a tutoriel for more help https://www.youtube.com/watch?v=AqQc3YqfelE

it works for me and i wish to work for you too.

Chedi
  • 11
  • 2
1

I had the same error. I resolved in this way

Go to start- MySQL Installer-community and run again the installer as a re-configuration(you will be asked so).

Once asked if you want make MySQL instance to run as a Windows service, check the box.

In case would do not work, try unistalling and installing again, and check the box to run MySQL as Windows service.

Carmine Tambascia
  • 1,628
  • 2
  • 18
  • 32
  • This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/12624235) – Andrew Jun 08 '16 at 20:52
  • Hi Andrew,thanks for the feedback, I changed it in a way answer the question(even not a question though but a report of an error, and I provide my solution to the same error) – Carmine Tambascia Jun 08 '16 at 21:55
  • This solved my problem! In particular, it was MySQL server that I needed to reconfigure and I was then prompted to add a password. Now I am (finally) able to successfully make a connection, having stored the password I just made. – Francisco C Jan 06 '21 at 16:22
1

From what I've gathered this means the mysql service (mysqld) isn't running.

  • First make sure it is installed as a windows service : Run

"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --install

from the command line.

  • Next, start it up :

services.msc > MySQL > start

If it fails to restart, then you can follow these steps :

  • open the command line as an administrator : cmd.exe > open as administrator
  • run "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld" --verbose

it should fail and put the error log in a directory named data under C:\Program Files\MySQL\MysSQL Server 5.7\ . If it fails to create data for some reason, do it manually under that directory and try again. If you can figure out what's missing from what's in that log, then good, you're done.

If you've still got no luck, this is how I did it :

  • goto C:\ProgramData\MySQL and copy the file named my.ini to C:\Windows\

  • try to start the service again from the command line : "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld" --verbose

If it doesn't display any error, than the service startup was successfull. If it's still not working, than delete that my.ini you just copied from C:\Windows and start the service from the command line once again.

it should work now

Paul Mira
  • 71
  • 1
  • 3
1

if it is showing error 2003 (HY000): Can't connect to MySQL server on localhost (10061) than

  1. Search services.msc in run
  2. goto mysql properties
  3. copy the mysql service name
  4. start cmd as administrator
  5. write: net start mysqlservicename .i.e mysql57 or etc it will show mysql is starting.
Christopher Moore
  • 3,071
  • 4
  • 30
  • 46
1

For me, three steps solved this problem on windows 10:

I downloaded MySQL server community edition zip and extracted it in the D drive. After that I went to bin folder and did cmd on that folder. I followed the below steps and all works:

D:\tools\mysql-8.0.17-winx64\bin>mysqld -install
Service successfully installed.

D:\tools\mysql-8.0.17-winx64\bin>mysqld --initialize
D:\tools\mysql-8.0.17-winx64\bin>net start mysql
The MySQL service is starting...
The MySQL service was started successfully.
Kevin
  • 16,549
  • 8
  • 60
  • 74
0

I too had this problem, its easy to solve:

Go to Control panel - System and maintenance - System - Advanced system settings - Environment variables - System variables - path - click edit - add

"c:\xampp\mysql\bin" - it should look like this :

\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\QuickTime Alternative\QTSystem;c:\xampp\mysql\bin

And don't forget to start MySQL from control panel of Xampp.

Valentin Despa
  • 40,712
  • 18
  • 80
  • 106
Siddharth Patel
  • 193
  • 1
  • 2
  • 15
  • Note, you need only add the ";c:\xampp\mysql\bin" part to the end of whatever other values exist there. – Ren Jun 03 '13 at 08:57
0

I found the same error re occurring even after I tried all the above solutions given above. I had even tried version 5.7 and few more. Guys don't waste your time trying to fix it. Rather install version 5.5. It's working perfectly fine without any unnecessary error.

Shruti
  • 1
0

Well in my case I just opened services.msc using run and restarted 2 of the services related to mysql and it worked!

Aditya
  • 1
0

In case of Xampp Installation.

Go to your xampp installation and mysql folder, for my case: C:\xampp\mysql

Run the file "resetroot.bat" from cmd or explorer.

My installation started working!!!

Sachin
  • 36
  • 4
0

The solution that fixed the issue was using the following steps:

In Start Menu, search for "mysql". Among the results, you should see the "MySQL Installer - Community". Run it. MySQL Installer window will show up as shown below. Find "MySQL Server" under Product and click on "Reconfigure" link. MySQL Installer Community

The MySQL Installer will show up (same one you used for the first MySQL Server installation). Go through all the steps.

After the MySQL Installer was finished, I started the MySQL service again.

ankit715
  • 45
  • 9
0

Don't do useless stuff like reconfigure, stop MySQL and start MySQL in service. Just reinstall the MYSQL server and again install it in your system. Remember only uninstall MySQL server and nothing else. All the problem will be solve automatically

0

The main reason for this kind of error is you might have uninstalled Mysql server application. Install it and then give it a go.

0

for who person that want use mysql or mariadb with out any error i suggest use version 5.5 just download a zip file mariadb-5.5.65-winx64.zip from https://downloads.mariadb.org/mariadb/5.5.65/ and to install follow this tutorial setp by step https://www.youtube.com/watch?v=uEPs6JsTZFc (this tutorial works well for version 5.5 too )

0

I had the same issue and basically resolved it by pointing to a specific port number that my MySQL server was running on. Below is the command. Please edit the code to fit your case i.e your port number,your mysql server username,your password.

    mysql -u root -pYourMysqlRootPassword -P3307 
Tom Munyiri
  • 156
  • 2
  • 5
0
  1. Create the temp folder c:/mysqltmp
  2. In my.ini file under [mysqld] add the line tmpdir=c:/mysqltmp
  3. Add full privileges to user NETWORK SERVICE for "C:\ProgramData\MySQL\MySQL Server X.Y\Data\ibdata1" file
  4. Start service

These are steps for the same problem with MySQL5.7 and MySQL8.0 on Windows 10

nesomis
  • 29
  • 7
0

This saved my life,

mysqld --tc-heuristic-recover=ROLLBACK

Read more

imsrsam
  • 11
  • 4
0

Turn off firewall and restart mysql server. then turn on firewall. It's the easy way! just try it

0

If you are using window:

  • Click on start
  • Search services and open
  • Check if MySql is running

Check if MySql is running...

ncutixavier
  • 455
  • 5
  • 4
0

For Wamp64 users, check the log files for unknown character-set or server-collation errors. I fixed my problem by editing my.ini [mysqld] with:

character-set-server=utf8mb4
collation-server=utf8_unicode_ci
Ron
  • 67
  • 4