Koozali.org: home of the SME Server

mySQLdb for python can't connect to mysql

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
mySQLdb for python can't connect to mysql
« on: May 14, 2007, 07:02:01 PM »
As part of an effort to install Django on SME 7.1, I compiled and installed the mySQLdb source. That seemed to go well. When I run the tests via django, python throws an error mysqldb.connect()

I added some classes per the django tutorial. Ran python manage.py syncdb, which connects to mySQL and creates tables in a predefined database.

Traceback (most recent call last):
  File "manage.py", line 11, in ?
    execute_manager(settings)
  File "/usr/lib/python2.3/site-packages/django/core/management.py", line 1674, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "/usr/lib/python2.3/site-packages/django/core/management.py", line 1573, in execute_from_command_line
    action_mapping[action](int(options.verbosity), options.interactive)
  File "/usr/lib/python2.3/site-packages/django/core/management.py", line 474, in syncdb
    _check_for_validation_errors()
  File "/usr/lib/python2.3/site-packages/django/core/management.py", line 1151, in _check_for_validation_errors
    num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.3/site-packages/django/core/management.py", line 974, in get_validation_errors
    db_version = connection.get_server_version()
  File "/usr/lib/python2.3/site-packages/django/db/backends/mysql/base.py", line 128, in get_server_version
    self.cursor()
  File "/usr/lib/python2.3/site-packages/django/db/backends/mysql/base.py", line 100, in cursor
    self.connection = Database.connect(**kwargs)
  File "/usr/local/examaid/__init__.py", line 74, in Connect
   
  File "/usr/lib/python2.3/site-packages/MySQL_python-1.2.2-py2.3-linux-i686.egg/MySQLdb/connections.py", line 170, in __init__
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (111)")


The user and database referenced in settings.py exists in mysql. Perhaps I overlooked or misunderstand a config for mysqldb?
- Mark

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
mySQLdb for python can't connect to mysql
« Reply #1 on: May 15, 2007, 07:28:55 PM »
A friend helped me solve this one, and it was trivial indeed. (Please don't shoot me)

In a config file called settings.py I named the host as "127.0.0.1". When I changed it to default to localhost, the connection succeeded.

Sorry for the noise.
- Mark