Monday, February 28, 2011

python mysqldb installation problem

OS: Ubuntu 10.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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment