0

I'm getting authentication error in connecting to remote Mysql. Code:

import MySQLdb as mdb

con = mdb.connect(host='xxx',port=3306,user= 'user', passwd='123',db= 'stellar')
cur = con.cursor()
cur.execute('show tables')
for r in cur:
    print(r)

Error:

Traceback (most recent call last):
  File "C:/staging_files/test.py", line 5, in <module>
    con = mdb.connect(host='xxx',port=3306,user= 'user', passwd='123',db= 'stellar')
  File "C:\Python34\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "C:\Python34\lib\site-packages\MySQLdb\connections.py", line 204, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'user'@'10.212.148.49' (using password: YES)")

I tried some of solutions suggested here. I ran command on Windows server hosting MySQL-

GRANT ALL ON DB.stellar TO user@xxx IDENTIFIED BY '123';

I also added- bind-address = 0.0.0.0 to my-default.cnf file

6
  • do you have skip-networking commented out in your my.cnf? Commented May 25, 2015 at 11:33
  • @JörnHees fthere is no option as skip-networking. Even there was no option as bind-address I added it myself. Commented May 25, 2015 at 12:22
  • stackoverflow.com/questions/29672480/… Commented May 25, 2015 at 13:30
  • @Akhil thanks. 1 question, the solution is for 1 IP. if i want to allow any host to connect to mysql server then how should I do it? Instead of xx.xx.xx.xx should I give 0.0.0.0 ? And user as well [email protected] Commented May 25, 2015 at 18:34
  • Remove bind-address completely from my.cnf. This means you are allowing "ALL" ip addresses Commented May 27, 2015 at 12:51

0

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.