I am using Python 2.7 on OSX Lion and can't connect to a remote SQL Db on Python. I get the following error:
Traceback (most recent call last):
File "connectDB.py", line 39, in <module>
main()
File "connectDB.py", line 16, in main
db = MySQLdb.connect(HOST, USER, PASSWORD, DBNAME )
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/__init__.py", line 81, in Connect
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/connections.py", line 187, in __init__
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'ekogan'@'dyn-209-2-217-168.dyn.columbia.edu' (using password: YES)")
I know my host and user/pass work because I'm able to access it via PHP. But for some reason it's denied here. Could there be some SQL versioning issues? I am totally unsure of how to proceed.
PHP probably does not access your MySQL server as a remote host. Python probably does. So check your permissions.
grant select,update,delete,insert on DBNAME.* to 'ekogan'@'dyn-209-2-217-168.dyn.columbia.edu' identified by 'PASSWORD';
If you have permission to inspect the mysql.user
table, open a terminal and type
% mysql -u ekogan -p mysql
mysql> select user, host, password from user where password = password(PASSWORD);
Above, change PASSWORD
to the value of your password surrounded by quotes, (ie if your password is foobar
, change PASSWORD
to "foobar"
). The user, host and password must match an entry in the mysql.user
table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.