Skip navigation links

MySQL Forums


Advanced Search

Python MySQLdb Connection Problem
Posted by: cyrnc ceyranci ()
Date: August 27, 2008 10:03AM

OS: Ubuntu 8.04
I am learning web developing with Django.I downloaded and installed python-mysql but i couldn't connect.I think problem is database settings.
Here is the process:

django-admin.py startproject mysite #creating a project and a mysite folder

files in 'mysite' folder:
/__init__.py
/urls.py
/manage.py
/views.py
/settings.py

Then i edited the 'settings.py' file.There are alse database settings in it.

Here are the settings:

DATABASE_ENGINE = 'mysql'
DATABASE_NAME = 'mydb'
DATABASE_USER = 'me'
DATABASE_PASSWORD = 'pwd'
DATABASE_HOST = ''
DATABASE_PORT = ''

then i write the codes below with terminal:

python manage.py shell

from django.db import connection
cursor=connection.cursor()

Then the error occurs as:

Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/django/db/backends/mysql/base.py", line 99, in cursor
self.connection = Database.connect(**kwargs)
File "/var/lib/python-support/python2.5/MySQLdb/__init__.py", line 74, in Connect
return Connection(*args, **kwargs)
File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line 170, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")


It looks like that error occurs from DATABASE_HOST but i don't think so because when using MySQL DATABASE_HOST may be left blank.

Thanks for your help...

Options: ReplyQuote


Subject Written By Posted
Python MySQLdb Connection Problem cyrnc ceyranci 08/27/2008 10:03AM
Re: Python MySQLdb Connection Problem Huu Da Tran 09/02/2008 11:31AM


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