Sample Header Ad - 728x90

Django can not connect to MySQL database over ubuntu 10.04

0 votes
1 answer
2236 views
I got a simple Django 1.3.* project, i would like to run it over my localhost. I installed all necessary modules like: python-mysqldb, rptz etc... I have ubuntu 10.04 installed with python 2.7.2. When i tried to start project in terminal thor@thor:/media/SAJAT - Projects/project/simple project$ python manage.py runserver I got the following error message: > Validating models... Unhandled exception in thread started by > Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in inner_run self.validate(display_num_errors=True) File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 249, in validate num_errors = get_validation_errors(s, app) File "/usr/lib/python2.7/dist-packages/django/core/management/validation.py", line 102, in get_validation_errors connection.validation.validate_field(e, opts, f) File "/usr/lib/python2.7/dist-packages/django/db/backends/mysql/validation.py", line 14, in validate_field db_version = self.connection.get_server_version() File "/usr/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 338, in get_server_version self.cursor() File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 250, in cursor cursor = self.make_debug_cursor(self._cursor()) File "/usr/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 322, in _cursor self.connection = Database.connect(**kwargs) 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: (2003, "Can't connect to MySQL server on '172.17.30.101' (110)") I have no idea where this IP address comes from 172.17.30.101' (110) because of my mysql server has been installed on my computer(localhost) Here is my settings.py file DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'dbname', # Or path to database file if using sqlite3. 'USER': 'dbuser', # Not used with sqlite3. 'PASSWORD': '123456', # Not used with sqlite3. 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. #'PORT': '3306', i tried with this too # Set to empty string for default. Not used with sqlite3. #'PORT': '3360', i tried with this too # Set to empty string for default. Not used with sqlite3. }, # 'read': { # 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. # 'NAME': 'newsonia', # Or path to database file if using sqlite3. # 'USER': 'dbuser', # Not used with sqlite3. # 'PASSWORD': 'dbname', # Not used with sqlite3. # 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3. # 'PORT': '', # Set to empty string for default. Not used with sqlite3. # } } I have no idea how should be resolve this kind of errors.
Asked by Nagy Ervin (11 rep)
Aug 16, 2014, 08:57 AM
Last activity: Aug 17, 2023, 08:02 AM