简体   繁体   English

无法从 Python 2.7 连接 MySQL。 (无法连接到本地主机)

[英]Unable to connect with MySQL from Python 2.7. (Unable to connect to localhost)

I am trying to run a module in python2.7 on my Windows 7 PC but it seems that I cannot connect with MySql server.我试图在我的 Windows 7 PC 上的 python2.7 中运行一个模块,但似乎我无法连接到 MySql 服务器。 The error I get is the following:我得到的错误如下:

OperationalError: (_mysql_exceptions.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' (10061)")

1) Python module I am trying to run: https://snipboard.io/eaZNSn.jpg 1)我试图运行的 Python 模块: https : //snipboard.io/eaZNSn.jpg

2) Error I get: https://snipboard.io/761UoR.jpg 2)我得到的错误: https : //snipboard.io/761UoR.jpg

3) MySql installer: https://snipboard.io/o35n2l.jpg 3)MySql安装程序: https : //snipboard.io/o35n2l.jpg

4) Windows Services: https://snipboard.io/CI9JPa.jpg , MySql80 starts properly, Mysql cannot start. 4)Windows服务: https ://snipboard.io/CI9JPa.jpg,MySql80正常启动,Mysql无法启动。

5) Mysql: https://snipboard.io/iuaVEA.jpg 5)Mysql: https : //snipboard.io/iuaVEA.jpg

What I have tried: installing the mysqld.exe from cmd.我尝试过的:从 cmd 安装 mysqld.exe。 https://snipboard.io/qYafIM.jpg https://snipboard.io/qYafIM.jpg

Are you sure that the MySQL server is running on port 10061?您确定 MySQL 服务器运行在端口 10061 上吗? The default port for MySQL is 3306. Try to connect using port 3306 from the python module. MySQL 的默认端口是 3306。尝试使用 python 模块中的端口 3306 进行连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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