connect to a database with MySQLdb on Leopard
Hello everyone!
I'm programming a software in python which need to access to a database. I thus installed MySQLdb but I have some little problems to connect to my database.
I'm running under masOSX Leopard 10.5.2, MySQL version is 5.0.51a (32bit), python 2.5 and I've got MySQLdb 1.2.1
I was previously running under Tiger and I had no problems. When upgrading to Leopard I had some little bugs so I choosed to reinstall my MySQL server (and MySQLdb packages).
When I'm connecting to mysql in root mode directly in the bash ("mysql -u root") I have no problem connecting to my database. But when I'm trying to connect with my python script I get an error.
I'm accessing with:
self.db=MySQLdb.connect("localhost","root","","ENS")
self.cursor=self.db.cursor()
where ENS is the name of the database I need to access to.
I get this error:
Traceback (most recent call last):
File "programme.py", line 63, in <module>
A = Applic_graph_princ()
File "programme.py", line 26, in __init__
self.DB=dbDialog.Dialog(port,login,pwd,name)
File "/Users/Guilhem/INSA/Biopylife/dbDialog.py", line 9, in __init__
self.db=MySQLdb.connect(port,login,pwd,name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/MySQLdb/__init__.py", line 75, in Connect
return Connection(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/MySQLdb/connections.py", line 164, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")
I thought I was connecting in root mode to my local server.
There is indeed no mysql.sock file in the tmp folder, but I checked my my.cnf file in etc and it should not connect there.
[client]
socket = /var/mysql/mysql.sock
[mysqld]
socket = /var/mysql/mysql.sock
I may also have a privilege problem because I also can't access to the database if I'm connecting to mysql without root mode.
ordinateur-de-guilhem-richard:~ Guilhem$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 45
Server version: 5.0.51a MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use ENS
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'ens'
Can someone help me??
By the way, do anyone know is there is some incompatibilies between MySQLdb and py2app? I had already some bugs on Tiger.
Thanks!!