简体   繁体   中英

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.

I am trying to connect with MySQL via python. I recently downloaded MySQL connect from Oracle. I also downloaded the ODBC driver from the same site. When I plug in the information below, I get a 2003 error telling me that it cannot connect:

mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1'

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. I have to hit control-z every time I want it to stop. Do I need mod_wsgi to fix this?

You're trying to connect to the http port (port 80) on your machine.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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