3

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.

1 Answer 1

1

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.