I am a newbie to Ubuntu Os and Xampp related stuff but has a good knowledge of python and django.I recently shifted from windows where i used wamp to run mysql.I installed Xampp on my ubuntu desktop instead of separately installing Mysql.The problem is that i cannot make python to connect to Mysql server running on localhost.
I have MYSQLdb connector module installed with my python 2.7.4.
Xampp starts fine and i can run SQL by typing mysql -u root
in the terminal.So as,the django manage.py utility shows the database client shell while running the following code:
black_perl@ank:~/Desktop/testproject$ python manage.py dbshell
Welcome to the MySQL monitor.
mysql>
But when i do :
>>> import MySQLdb as m
>>> a=m.connect(user="root",passwd="",db="test_project")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
I cannot find any directory /var/run/mysqld. I have my mysql at /opt/lampp/bin/mysql.I tried the other solutions as mentioned on the other related questions here on the stackoverflow but no help. Correct me if i'm wrong somewhere. Regards.