简体   繁体   English

MySQL Connect,XAMPP和ODBC

[英]MySQL Connect, XAMPP and ODBC

Note:**I am connecting using Python2.7 in a virtualenv to access MySQL on XAMPP, which was not installed on the virtualenv. 注意:**我正在在virtualenv中使用Python2.7进行连接,以在XAMPP上访问MySQL,而XAMPP尚未安装在virtualenv上。

I am trying to connect with MySQL via python. 我正在尝试通过python与MySQL连接。 I recently downloaded MySQL connect from Oracle. 我最近从Oracle下载了MySQL connect。 I also downloaded the ODBC driver from the same site. 我还从同一站点下载了ODBC驱动程序。 When I plug in the information below, I get a 2003 error telling me that it cannot connect: 当我插入以下信息时,出现2003错误,告诉我它无法连接:

mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1' mysql.connector.errors.InterfaceError:2003:无法连接到“ 127.0.0.1”上的MySQL服务器

but when I include the port number in my connection, it freezes up and nothing happens. 但是当我在连接中包含端口号时,它冻结了,什么也没发生。

This is my code: 这是我的代码:

>>>import mysql.connector
>>>cnx = mysql.connector.connect(user='[my username]',password='[my password]',host='127.0.0.1', database='FXPrices',port=80)

After that, the cursor indents--so there are no arrows for the python prompt. 之后,光标会缩进-因此python提示符没有箭头。 I have to hit control-z every time I want it to stop. 每当我要停止它时,我都必须按Control-z。 Do I need mod_wsgi to fix this? 我需要mod_wsgi来解决此问题吗?

You're trying to connect to the http port (port 80) on your machine. 您正在尝试连接到计算机上的http端口(端口80)。

MySQL by default listens to port 3306, you shoud try that (it's the same if you omit the port argument), or try to find out on which port your mysql server is really listening. MySQL默认情况下监听端口3306,您应该尝试尝试该端口号(如果省略port参数,这是相同的),或者尝试找出您的mysql服务器真正在哪个端口上监听。

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

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