安装后无法连接到 'localhost' (10061) 上的 MySQL 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10892689/
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
Can't connect to MySQL server on 'localhost' (10061) after Installation
提问by The Original Android
I installed MySQL using mysql-installer-5.5.20.0.msion 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.
我在 Windows 7 上使用mysql-installer-5.5.20.0.msi安装了 MySQL 。从 cmd 窗口,我运行“mysqlshow -u root -p”。它要求输入密码,然后返回此错误:“无法连接到 'localhost' (10061) 上的 MySQL 服务器”这是部分失败/成功安装的不良迹象。
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.
阅读页面http://dev.mysql.com/doc/refman/5.5/en/windows-troubleshooting.html 后,它告诉我在 C:\Program Files\MySQL\ 中找到错误日志(.err) MySQL 服务器 5.5\数据。该目录存在但没有日志文件。
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.
我有一种感觉,这与 Windows 7 的严密安全性有关,尤其是在安装基于 Unix 的软件时。是的,我是我 PC 上的管理员。
Any help or suggestions is appreciated. And I can return a favor by answering Java and SQL query questions.
任何帮助或建议表示赞赏。我可以通过回答 Java 和 SQL 查询问题来回报我的帮助。
采纳答案by shay lami
this issue is very to solve by windows server users
这个问题非常需要 windows server 用户解决
go to this path C:\Program Files\MySQL\MySQL Server 5.1\bin
run this tool "MySQLInstanceConfig.exe"
转到此路径 C:\Program Files\MySQL\MySQL Server 5.1\bin
运行这个工具“MySQLInstanceConfig.exe”
and config the instatnce again and problem solved
并再次配置实例并解决问题
回答by maheshDeshmukh
Please Try the following steps:
请尝试以下步骤:
- c:\mysql\bin>mysqld --install
- c:\mysql\bin>mysqld --initialize
- c:\mysql\bin>mysqld --install
- c:\mysql\bin>mysqld --initialize
then press "Windows key + R" write "services.msc", run as admin
然后按“ Windows键+R”写入“ services.msc”,以管理员身份运行
start MySQL service.
启动 MySQL 服务。
回答by Programming-Lover
I also faced the same issue and resolved it by below setups:
我也遇到了同样的问题并通过以下设置解决了它:
Check the MYSQLservice 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.
在windows服务中查看MYSQL服务。如果它在那里并且没有运行,则启动它。它会解决你的问题。
您可以通过导航到 Windows 开始菜单并在搜索栏中键入“服务”来找到服务窗口。选择旁边带有齿轮的“服务”选项(不是可执行文件),将出现以下窗口。向下滚动以找到“MySql(版本)”。当您选择 MySql 时,您应该会在左侧窗格中看到一个选项,上面写着“启动服务”。单击此按钮,应出现一个对话框,指示 Windows 正在尝试启动该服务。启动后,左窗格现在将为您提供停止、暂停和重新启动服务的选项,您现在可以从 Windows cmd 行连接到您的 MySql。
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.
如果 Windows 服务中不存在 MYSQL 服务,请按照以下设置进行操作。
一种。以管理员身份打开cmd。
湾 cd 到C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin
C。运行命令: C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin>mysqld.exe --install
d. 检查windows服务中的MySql,如果没有运行,点击服务启动。
e. 如果您使用 XAMMP 。在 XAMMP 控制面板上启动 MySQL。
回答by Keramat
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.
对我有用的简单解决方案是:在 database.yml 或脚本中将 localhost 更改为 127.0.0.1(如果编写)。
回答by Frederik Struck-Sch?ning
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 :)
我有这个错误 - 愚蠢的错误是,我-p3307
用来指定端口,而我应该使用-P3307
,即大写 P。小“p”是密码 arg :)
回答by Charles Robertson
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.
如果没有--host
和--port
参数,特别是如果您将端口更改为 3307,这是一个非默认值,将导致此错误。
回答by nikhil
In Windows 7
在 Windows 7 中
- press Windows+R it opens Run
- Enter services.msc
- Find out mysql right click and start
- if mysql was not found
- Run cmd as administrator
- goto C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin directory(to go back use cd..) and type
mysqld.exe --install
- follow step 3
- 按 Windows+R 它打开运行
- 输入 services.msc
- 找出mysql右键启动
- 如果找不到 mysql
- 以管理员身份运行cmd
- 转到 C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin 目录(返回使用 cd..)并输入
mysqld.exe --install
- 按照步骤 3
That's all
就这样
回答by Avilio
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.
我有 Windows 8.1,我也有这个问题。我的老师告诉我这可能是因为我的 MySQL 服务器已停止运行。她让我进入“计算机管理”实用程序(右键单击 Windows 8.1 屏幕左下角以访问“计算机管理”)。然后在服务和应用程序下,打开服务并找到 MySQL。您应该能够右键单击 MySQL 并重新启动它。
回答by joedavid
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.
对于 5.7 版本,我遇到了同样的问题,一个简单的修复就解决了这个问题。在安装工作台 5.7 时,还有另一种称为“MySQL 安装程序社区”的“软件”。我运行了这个并为 MySQL 服务器运行了“重新配置”。花了大约一分钟,问题不再存在。
Hope it works!.(Keep in mind i was using the 5.7 version)
希望它有效!.(请记住我使用的是 5.7 版本)
回答by neo.abi1000
if it is showing error 2003 (HY000): Can't connect to MySQL server on localhost (10061) than
如果它显示错误 2003 (HY000): Can't connect to MySQL server on localhost (10061) than
- Search services.msc in run
- goto mysql properties
- copy the mysql service name
- start cmd as administrator
- write: net start mysqlservicename .i.e mysql57 or etc it will show mysql is starting.
- 在运行中搜索 services.msc
- 转到 mysql 属性
- 复制mysql服务名
- 以管理员身份启动cmd
- 写:net start mysqlservicename .ie mysql57 or etc 它会显示mysql正在启动。