OS: RHEL Python Version: 3.6 SQLAlchemy Version: 1.1.10 PyMySQL Version: 0.7.11 MySQL Distrib: 5.7.17-13
import pymysql conn = pymysql.connect(host='localhost', port=3306, user='testuser', passwd='###########', db='mysql') cur = conn.cursor() cur.execute("SELECT Host,User FROM user") print(cur.description) print() for row in cur: print(row) cur.close() conn.close() When I try to execute the above code I'm getting the following error message, but I'm still able to connect to mysql using the same account and password via command line.
pymysql.err.OperationalError: (1045, "Access denied for user 'testuser'@'127.0.0.1' (using password: YES)") I tried searching all over the internet for this error message but I could not figure out the actual issue. I would really appreciate if anyone could help me fix this issue.