错误 2003:无法连接到“本地主机”上的 MySQL 服务器 (10061)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8565597/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error 2003: Can't connect to MySQL server on 'localhost' (10061)
提问by user1106278
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,所以我下载了适用于 Windows 7 的 MySQL v5.5 并选择了开发人员设置。我打开命令提示符,输入
mysql -u root -p
and get the following: error
并得到以下信息:错误
2003: Can't connect to MySQL server on 'localhost' (10061)
2003:无法连接到“本地主机”上的 MySQL 服务器 (10061)
How do i fix this? I type:
我该如何解决?我输入:
sc query mysql
and get:
并得到:
STATE: 1 STOPPED
状态:1 停止
I try:
我尝试:
sc start mysql
and get:
并得到:
[SC] StartService: OpenService FAILED 5: Access is Denied.
[SC] StartService:OpenService 失败 5:访问被拒绝。
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:
MySQL55 已启动,但 MySQL 已停止。MySQL 正在查找 MySQL Server 5.1 文件夹,所以我不确定为什么需要它,但是当我尝试启动它时,我得到:
"Windows could not start the MySQL Service on Local Computer. Error 2: They system cannot find the file specified".
“Windows 无法在本地计算机上启动 MySQL 服务。错误 2:他们的系统找不到指定的文件”。
Thanks.
谢谢。
采纳答案by user1106278
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.
经过大约 15 个小时的努力,我无法从命令提示符调用 mysql,所以我退出了。相反,我安装了 4.1.22 版。如果你去mysql主网页,你不会在存档中找到4.1.22。相反,我在 google 中搜索了 mysql 4.1。希望他们在您尝试时没有将其删除。
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.
我下载了“Essentials Package”并选择了“典型安装”选项。然后我转到开始 - > MySQL ... MySQL 服务器实例配置向导并选择“安装为 Windows 服务”和“包含 Bin 目录”。有一个下拉框,我可以在其中选择名称,例如“MySQL”或其他名称。当我选择“MySQL”时,它抱怨说我已经安装了。我改了,然后安装。从那里,我可以从命令行调用“mysql”。
If you can't find v4.1 or want to use v5, something along the lines of:
如果您找不到 v4.1 或想使用 v5,请执行以下操作:
http://www.devside.net/guides/windows/mysql
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.
可以通过修改工作,但在按照他们的说明操作后它不起作用,除了使用版本 5.5 而不是 v5.1。
Good luck.
祝你好运。
回答by Ehsan Masoudi
For the other newbie people who have the same problem as me (windows 7 64 bit):
对于与我有同样问题的其他新手(Windows 7 64位):
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:
MySQL 安装程序的早期版本根本不设置 Windows 服务(David Newcomb)。我花了 2 天的时间在谷歌上搜索并遇到了很多对我不起作用的令人困惑的答案,然后我找到了以下解决方案:
net start mysql
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.
,当服务安装好后,你应该可以输入上面的命令来启动服务。我的 mysql 版本是 5.6(最新版本),因此您不必按照建议安装旧版本。
See MySQL Error 2003: Can't connect to MySQL server on 'localhost',thank to @David Newcombresponse.
请参阅MySQL 错误 2003:无法连接到 'localhost' 上的 MySQL 服务器,感谢@David Newcomb 的响应。
回答by Aryan
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.
检查是否安装了 MYSQL 服务services.msc
如果没有,请转到 services.msc 并检查 Windows 防火墙是否已启动。如果是,停止它。
- open cmd as an administrator and go to bin folder of your MYSQL installation.
- type mysqld --install. It will successfully install service.
- 以管理员身份打开 cmd 并转到 MYSQL 安装的 bin 文件夹。
- 输入 mysqld --install。它将成功安装服务。
Now start the MYSQL services and try to configure the same.
现在启动MYSQL服务并尝试配置相同的。
回答by Subhajit Sarkar
open cmd in admin mode and type
在管理员模式下打开cmd并输入
cd C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\ mysql --defaults-file="C:\Program Files (x86)\MySQL\MySQL Server 5.0\my.bin" -u root -p在哪里 C:\Program Files (x86)\MySQL\MySQL Server 5.0\C:\Program Files (x86)\MySQL\MySQL Server 5.0\是你的安装目录,my.inimy.ini是配置文件。
回答by Napolean
回答by Avinav K
By far the easiest way to get your mysql server installed and configured is to download and use the 'MySQL Installer', which should solve your problem.
到目前为止,安装和配置 mysql 服务器的最简单方法是下载并使用“MySQL 安装程序”,它应该可以解决您的问题。
回答by Sankar R.K
Start MySql service from Control panel.
从控制面板启动 MySql 服务。
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
在 windows 7 控制面板\所有控制面板项\管理工具中启用 MySql 服务 打开“服务”然后启用 MySql 服务
从命令提示符 mysql -u root -p mysql 并输入密码为 admin,这是默认密码
This will work
这将工作
回答by Thirumal
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.
转到运行类型services.msc
。检查 MySQL 服务是否正在运行。如果没有,请手动启动。启动后,键入 mysqlshow 以测试该服务。
回答by Aarti kumari
here are a few steps which you have to follow which work in my case:
以下是您必须遵循的几个步骤,在我的情况下是有效的:
step1:open cmd
with dir as C:\mysql\bin
step1:cmd
用dir
打开C:\mysql\bin
step 2:type C:\mysql\bin>mysqld --console
hit Enter
第 2 步:键入C:\mysql\bin>mysqld --console
命中Enter
step 3:again open cmd with dir C:\mysql\bin>
第 3 步:再次使用 dir 打开 cmdC:\mysql\bin>
step 4:type command:
C:\mysql\bin>mysql -u root -p
enter password : ****(whatever your password)
hit Enter
第 4 步:输入命令:
C:\mysql\bin>mysql -u root -p
enter password : ****(whatever your password)
hitEnter
step 5 :you can be able to see
mysql> {write your mysql queries here}
第5步:你可以看到
mysql> {write your mysql queries here}
回答by Priya
The first thing you need to check is whether the service is running or not.
您需要检查的第一件事是服务是否正在运行。
If not start the mysql service.
如果没有启动mysql服务。
To start the MySQL service:
启动 MySQL 服务:
In Windows 10 Press Windows key ,type services open as Administrator and right click on that mysql service to start.
在 Windows 10 中按 Windows 键,键入以管理员身份打开的服务,然后右键单击该 mysql 服务以启动。
Check the port number if not default 3306 ,then need to mention
检查端口号如果不是默认的3306,则需要提及
like mysql -u root -ppassword --port=3307 referred this link. http://dba.fyicenter.com/faq/mysql/Connect-to-MySQL-on-Specific-Port.html
就像 mysql -u root -ppassword --port=3307 提到了这个链接。 http://dba.fyicenter.com/faq/mysql/Connect-to-MySQL-on-Specific-Port.html