MySQL Forums
Forum List  »  Connector/Python

MySQLdb connection issues
Posted by: Jonathan De Weese
Date: September 01, 2016 08:01PM

I'm having issues connecting to mysql from my python script, here is what i get,

[jonathan@hosname sql_scripts]$ python sql.py
Traceback (most recent call last):
File "sql.py", line 14, in <module>
sql_connection = mdb.connect(sql_host,sql_username,sql_password,sql_database)
File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 81, in Connect
File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 193, in __init__
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'jonathan'@'localhost' (using password: YES)"

Here are my versions:

Python 2.7.5 (default, Oct 1 2013, 20:49:11)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> MySQLdb.version_info
(1, 2, 5, 'final', 1)
>>>

[jonathan@hostname sql_scripts]$ mysql -V
/db/mysql/current/bin/mysql Ver 14.14 Distrib 5.6.16-64.2, for Linux (x86_64) using EditLine wrapper
[jonathan@hostname sql_scripts]$

mysql> SHOW GRANTS FOR 'jonathan'@'localhost';
+------------------------------------------------------------------------------------------------------------------+
| Grants for jonathan@localhost |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'jonathan'@'localhost' IDENTIFIED BY PASSWORD '*D1D13DBB11064ACBE5BAA7A8516D722F27E258AF' |
| GRANT ALL PRIVILEGES ON `NetInventory`.* TO 'jonathan'@'localhost' |
+------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql>


mysql> SELECT user,host,password FROM mysql.user;
+-----------+--------------------------------+-------------------------------------------+
| user | host | password |
+-----------+--------------------------------+-------------------------------------------+
| root | localhost | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| root | hostname
| *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| root | 127.0.0.1 | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| root | ::1 | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| | localhost | |
| | hostname
| |
| dbadmin | localhost | *125EA03B506F7C876D9321E9055F37601461E970 |
| repl | % | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
| jonathan | localhost | *D1D13DBB11064ACBE5BAA7A8516D722F27E258AF |
+-----------+--------------------------------+-------------------------------------------+
9 rows in set (0.00 sec)

mysql>

Any ideas?

Options: ReplyQuote


Subject
Written By
Posted
MySQLdb connection issues
September 01, 2016 08:01PM
November 15, 2016 04:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.