I have python code that looks like
import MySQLdb import sys try: con = MySQLdb.connect(host = 'localhost',user = 'crawler',passwd = 'crawler', db = 'real_estate_analytics')
The problem is that I get the following error:
Error 1045: Access denied for user 'crawler'@'localhost' (using password: YES)
If I mysql on the terminal mysql -u crawler -pcrawler , I can easily access the databases.
mysql> show databases; +-----------------------+ | Database | +-----------------------+ | information_schema | | AL | | cloversoup | | codebar | | mysql | | performance_schema | | real_estate_analytics | | teste | +-----------------------+ 8 rows in set (0.00 sec)
I also deleted an anonymous user to avoid collisions. My users
mysql> select user,host from mysql.user; +---------+-----------+ | user | host | +---------+-----------+ | root | % | | crawler | localhost | | root | localhost | +---------+-----------+ 3 rows in set (0.00 sec)
I have provided all grants for the crawler (and privileges dropped), so this should not be a problem:
GRANT ALL PRIVILEGES ON *.* TO crawler@localhost IDENTIFIED BY 'crawler' WITH GRANT OPTION;
FLUSH PRIVILEGES;
in fact:
mysql> show grants; +-------------------------------------------------------------------------------------------------------------------------------------------+ | Grants for crawler@localhost | +-------------------------------------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'crawler'@'localhost' IDENTIFIED BY PASSWORD '*A594DECC46D378FDA13D7843740CBF4985E6969B' WITH GRANT OPTION | +-------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
I also tried connecting using the root by doing
con = MySQLdb.connect(host = 'localhost',user = 'root',passwd = 'my_root_password', db = 'real_estate_analytics')
but it does not work (same error).
This thing is driving me crazy. Does anyone know what might be the problem?
OBS: I know there are similar questions on SO, but I read all of them, and this did not solve my problem. That is why I post it here