Sunday, April 28, 2013

Re: OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")

try to define the parameters so

'ENGINE': 'django.db.backends.mysql',       'NAME': 'yourdbname',                            'USER': 'root',                            'PASSWORD': 'your password',               'HOST': '',                       'PORT': '3306', 

El domingo, 6 de enero de 2013 05:42:21 UTC-5, ANKIT BAGARIA escribió:

    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'django',                      # Or path to database file if using sqlite3.
        'USER': 'name',                      # Not used with sqlite3.
        'PASSWORD': 'pass',                  # Not used with sqlite3.
        'HOST': '/var/run/mysql',           # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.

this is my setting in file. I have Mysql server running .Now I run python shell to start python interpreter. Then in the interreter I type the following command to check the connection to database:
>>>from django.db import connection
>>>cursor = connection.cursor()

and it gives me the following error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python27\lib\site-packages\django\db\backends\", line 306,
 in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "C:\Python27\lib\site-packages\django\db\backends\mysql\", line 38
7, in _cursor
    self.connection = Database.connect(**kwargs)
  File "C:\Python27\lib\site-packages\MySQLdb\", line 81, in Connect
    return Connection(*args, **kwargs)
  File "C:\Python27\lib\site-packages\MySQLdb\", line 187, in __in
    super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")

 I am using windows 7.
please help me fix it. it is driving me crazy. I have googled it, gone through different forums but am not able to fix it. Please help me.

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment