Hey Kevin, Thanks for your correct reply, I had this problem also but after changing host from "localhost" to "127.0.0.1" problem solved, But why? what's the different between 'localhost' and '127.0.0.1'?
On Wednesday, February 4, 2009 9:15:32 PM UTC+3:30, Kevin Audleman wrote: > > I found the solution in the archives: I changed DATABASE_HOST to > 127.0.0.1 from '' > > Kevin > > On Feb 4, 9:41 am, Kevin Audleman <kevin.audle...@gmail.com> wrote: > > Hello everyone, > > > > I am running through the tutorial and setting up my first django > > project. Quite exciting! However I have run into trouble connecting to > > MySQL. My settings.py file looks like this: > > > > DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', > > 'postgresql', 'mysql', 'sqlite3' or 'oracle'. > > DATABASE_NAME = 'test' # Or path to database file if using > > sqlite3. > > DATABASE_USER = 'root' # Not used with sqlite3. > > DATABASE_PASSWORD = '' # Not used with sqlite3. > > DATABASE_HOST = '' # Set to empty string for localhost. > > Not used with sqlite3. > > DATABASE_PORT = '' # Set to empty string for default. Not > > used with sqlite3. > > > > Yes, the username is 'root' and there is no password. This is on my > > local machine (OS X 10.5) so it doesn't matter. > > > > When I run... > > > > $ python manage.py syncdb > > > > I get the following... > > > > Traceback (most recent call last): > > File "manage.py", line 11, in <module> > > execute_manager(settings) > > File "/Library/Python/2.5/site-packages/django/core/management/ > > __init__.py", line 340, in execute_manager > > utility.execute() > > File "/Library/Python/2.5/site-packages/django/core/management/ > > __init__.py", line 295, in execute > > self.fetch_command(subcommand).run_from_argv(self.argv) > > File "/Library/Python/2.5/site-packages/django/core/management/ > > base.py", line 192, in run_from_argv > > self.execute(*args, **options.__dict__) > > File "/Library/Python/2.5/site-packages/django/core/management/ > > base.py", line 218, in execute > > self.validate() > > File "/Library/Python/2.5/site-packages/django/core/management/ > > base.py", line 246, in validate > > num_errors = get_validation_errors(s, app) > > File "/Library/Python/2.5/site-packages/django/core/management/ > > validation.py", line 65, in get_validation_errors > > connection.validation.validate_field(e, opts, f) > > File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ > > validation.py", line 8, in validate_field > > db_version = connection.get_server_version() > > File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ > > base.py", line 277, in get_server_version > > self.cursor() > > File "/Library/Python/2.5/site-packages/django/db/backends/ > > __init__.py", line 56, in cursor > > cursor = self._cursor(settings) > > File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ > > base.py", line 262, in _cursor > > self.connection = Database.connect(**kwargs) > > File "/Users/audleman/django_projects/pollster/__init__.py", line > > 74, in Connect > > > > File "/Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5- > > macosx-10.5-i386.egg/MySQLdb/connections.py", line 170, in __init__ > > _mysql_exceptions.OperationalError: (2002, "Can't connect to local > > MySQL server through socket '/tmp/mysql.sock' (2)") > > > > I'm not exactly sure what this socket is or why django can't find it. > > One thought is that I installed LAMP on my machine using XAMPP, which > > puts everything in the /Applications/xampp directory. Poking around, I > > managed to find a mysql.sock file here: > > > > /Applications/xampp/xamppfiles/var/mysql/mysql.sock > > > > Assuming this is the correct socket, how do I tell django where to > > find it? > > > > Thanks, > > Kevin -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/0dD75LGNe6UJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.