Question

I've read everything possible and I just can't connect to my mysql server. Here is my code. very simple. (I used xxx to hide all the private info. everything else is the way i got it.

import mysql.connector

conn = mysql.connector.connect(user='xxxx',password='xxxxx',host='xxxx',db='xxx',port=3306)

The login info is definitely correct. I tried it in a mysql client and it connected just fine. The MySQL server is hosted on dreamhost. I set the allowable IPs for the db user to wildcard %.%.%.% so anyone could connect.I don't know what else could possibly be wrong. When I try to connect in python i get:

C:\Python33\python.exe D:/Dropbox/python/v2/test.py
Traceback (most recent call last):
  File "D:/Dropbox/python/v2/test.py", line 3, in <module>
    conn = mysql.connector.connect(user='xxx',password='xxx',host='xxx',db='xxx',port=3306)
  File "C:\Python33\lib\site-packages\mysql\connector\__init__.py", line 101, in connect
    return MySQLConnection(*args, **kwargs)
  File "C:\Python33\lib\site-packages\mysql\connector\connection.py", line 117, in __init__
    self.connect(**kwargs)
  File "C:\Python33\lib\site-packages\mysql\connector\connection.py", line 383, in connect
    self._open_connection()
  File "C:\Python33\lib\site-packages\mysql\connector\connection.py", line 350, in _open_connection
    self._ssl)
  File "C:\Python33\lib\site-packages\mysql\connector\connection.py", line 176, in _do_auth
    raise errors.get_exception(packet)
mysql.connector.errors.ProgrammingError: 1044 (42000): Access denied for user 'xxx'@'%.%.%.%' to database 'xxx'

Any help would be greatly appreciated.

Was it helpful?

Solution

You will have to GRANT permissions to the user. Something like:

GRANT ALL PRIVILEGES ON *.* TO 'user2'@'localhost' IDENTIFIED BY PASSWORD 'xxxxx'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top