简体   繁体   中英

error 2003: Can't connect to MySQL server on 'localhost' (10061)

I'm trying to learn MySQL, so I downloaded MySQL v5.5 for windows 7 and chose the Developer settings. I open a command prompt, enter

mysql -u root -p

and get the following: error

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

How do i fix this? I type:

sc query mysql

and get:

STATE: 1 STOPPED

I try:

 sc start mysql

and get:

[SC] StartService: OpenService FAILED 5: Access is Denied.

I also checked: Control Panel:Administrative Tools:Services

MySQL55 is started, but MySQL is stopped. MySQL is looking the MySQL Server 5.1 folder, so I'm not sure why I would need it, but when I try to start it, I get:

"Windows could not start the MySQL Service on Local Computer. Error 2: They system cannot find the file specified".

Thanks.

For the other newbie people who have the same problem as me (windows 7 64 bit):

Early versions of the MySQL installer does not set up the windows service at all (David Newcomb). I have spent 2 days googling and faced a lot of confusing answers that did not worked for me, then I found the following solution:

net start mysql

,when the service is installed you should be able to enter the above command to start the service. my version of mysql is 5.6 (the newest one up to know), so you do not have to install the old versions as it is suggested.

See MySQL Error 2003: Can't connect to MySQL server on 'localhost' ,thank to @David Newcomb response.

I couldn't call mysql from the command prompt after about 15 hours of effort, so I quit. Instead, I installed version 4.1.22. If you go to mysql main webpage, you won't find 4.1.22 in the archive. Instead, I searched for mysql 4.1 in google. Hopefully they haven't removed it when you try it.

I downloaded the "Essentials Package" and chose the "typical install" option. I then went to Start -> MySQL ... MySQL Server Instance Config Wizard and chose "Install as Windows Service" and "Include Bin Directory". There's a drop down box where I could choose the name, like "MySQL" or something else. It complained when I chose "MySQL", saying that I already had an installation. I changed it, then it installed. From there, I could call "mysql" from the command line.

If you can't find v4.1 or want to use v5, something along the lines of:

http://www.devside.net/guides/windows/mysql

may work with modification, but it didn't work after following their instructions, with the exception of using version 5.5 instead of v5.1.

Good luck.

Check if MYSQL service is installed in services.msc In case not, go to services.msc & check if windows firewall is up. if yes, stop it.

  1. open cmd as an administrator and go to bin folder of your MYSQL installation.
  2. type mysqld --install. It will successfully install service.

Now start the MYSQL services and try to configure the same.

Start MySql service from Control panel.

Enabling MySql service in windows 7 Control Panel\\All Control Panel Items\\Administrative Tools Open "Services" then enable MySql service
From command prompt mysql -u root -p mysql and enter the password as admin, which is the default password

This will work

Go to Run type services.msc . Check whether MySQL services is running or not. If not, start it manually. Once it started, type mysqlshow to test the service.

open cmd in admin mode and type

where is your installation directory and is configuration file. 是您的安装目录,而是配置文件。

In windows 10, I faced similar issue and above commands didn't work for me.

But when I started service from the taskbar option didn't knew there was taskbar item to do so.

Adding a screenshot to show where exactly it appears 在此处输入图片说明

到目前为止,安装和配置mysql服务器的最简单方法是下载并使用“ MySQL Installer”,这应该可以解决您的问题。

here are a few steps which you have to follow which work in my case:

step1: open cmd with dir as C:\\mysql\\bin

step 2: type C:\\mysql\\bin>mysqld --console hit Enter

step 3: again open cmd with dir C:\\mysql\\bin>

step 4: type command: C:\\mysql\\bin>mysql -u root -p enter password : ****(whatever your password) hit Enter

step 5 : you can be able to see mysql> {write your mysql queries here}

The first thing you need to check is whether the service is running or not.

If not start the mysql service.

To start the MySQL service:

In Windows 10 Press Windows key ,type services open as Administrator and right click on that mysql service to start.

Check the port number if not default 3306 ,then need to mention

like mysql -u root -ppassword --port=3307 referred this link. http://dba.fyicenter.com/faq/mysql/Connect-to-MySQL-on-Specific-Port.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM