MySql 错误 ERROR 2003 (HY000):无法连接到“本地主机”上的 MySQL 服务器 (10061)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23738610/
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
MySql Error ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
提问by CodyBugstein
I'm following Vogella's tutorial on MySQLand I'm hitting a brick wall when I try to imitate the example. I've installed MySQL, and as he instructs I run it from the command line. When I do so, I get this error:
我正在关注Vogella 的 MySQL 教程,当我尝试模仿该示例时,我遇到了麻烦。我已经安装了 MySQL,并按照他的指示从命令行运行它。当我这样做时,我收到此错误:
C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.9>mysql -u root -p
Enter password: ******
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.9>
Does anyone know why?
有谁知道为什么?
回答by Vrajesh Doshi
The solution is very simple. The problem is the mysql service is not started. So we first need to start the mysql service before 'mysql -u user_name -p' command. To do that, navigate to 'bin' folder of mysql in command prompt. E.g:
解决方法很简单。问题是mysql服务没有启动。所以我们首先需要在'mysql -u user_name -p'命令之前启动mysql服务。为此,请在命令提示符下导航到 mysql 的“bin”文件夹。例如:
C:\Program Files\MySQL\MySQL Server 5.7\bin>
In your case probably,
在你的情况下,可能
C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.9\bin>
or
或者
C:\Program Files (x86)\MySQL\bin>
or
或者
If you have XAMPP installed, then to start mysql associated with it, navigate to
如果您安装了 XAMPP,那么要启动与之关联的 mysql,请导航到
C:\xampp\mysql\bin>
then type the command mysqld -u root -p
然后输入命令 mysqld -u root -p
It will output:
它会输出:
'2017-04-04 13:40:27 8536 [Note] mysqld (mysqld 10.1.21-MariaDB) starting as process 5640 ...'
'2017-04-04 13:40:27 8536 [注意] mysqld (mysqld 10.1.21-MariaDB) 从进程 5640 开始......'
This shows mysql is started.
这表明mysql已启动。
Now type your command mysql -u root -p
, it will work for sure.
现在输入您的命令mysql -u root -p
,它肯定会起作用。
回答by Mariah
try restarting the MYSQL app in the XAMPP control panel. It worked for me. Good luck!
尝试在 XAMPP 控制面板中重新启动 MYSQL 应用程序。它对我有用。祝你好运!
回答by JGutierrezC
Go to Start->Run and type services.msc. That's how you get to windows services window. Look for MySQL Server, Right Click, Start Service.
转到“开始”->“运行”并键入 services.msc。这就是你如何进入 Windows 服务窗口。查找 MySQL 服务器,右键单击,启动服务。
You could also get to Windows Services Window by Start -> Control Panel -> Administrative Tools -> Services
您也可以通过开始 -> 控制面板 -> 管理工具 -> 服务进入 Windows 服务窗口
If there's no such service MySQL Server, then install MySQL Server from here https://dev.mysql.com/downloads/mysql/
如果没有这样的服务 MySQL Server,那么从这里安装 MySQL Server https://dev.mysql.com/downloads/mysql/
回答by Proteeti Prova
Open the Xampp control panel and start the mysql module. For wamp, do the same. This is the simplest ever solution I've got !
打开 Xampp 控制面板并启动 mysql 模块。对于 wamp,做同样的事情。这是我有史以来最简单的解决方案!
回答by lpiert
mysql --protocol=TCP -P3306 -u user -p
mysql --protocol=TCP -P3306 -u 用户 -p