I was trying to access the database from my python program by:
db = mysql.connect(host = 'localhost', user = 'Max', passwd = 'maxkim', db = 'TESTDB')
cursor = db.cursor()
But, I get an error message in the first line of code.
OperationalError: (1045, "Access denied for user 'Max'@'localhost' (using password: YES)")
To remedy the situation, I did the following:
$ mysql -u Max-p
Enter password: maxkim
mysql> create database TESTDB;
mysql> grant usage on *.* to Max@localhost identified by ‘maxkim’;
mysql> grant all privileges on TESTDB.* to Max@localhost ;
mysql> exit
If I have granted all access to the the database for the user "Max" (me), why can't I still connect in python?
You can try adding GRANT OPTION at the end:
GRANT all privileges on TESTDB.* to 'Max'@'localhost' IDENTIFIED BY 'maxkim' WITH GRANT OPTION;
You can also use the below command to find the grants for a user:
SHOW GRANTS FOR 'Max'@'localhost';
Also See:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With