Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I’m using Django Bitnami Stack on Amazon EC2. I’m attempting to sync the database for the initial setup but I am having problems.

When running the following command I receive an error message: Python manage.py syncdb

"Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

I understand this as not being able to establish a connection to MySQL server. However when I run this from the command line I can connect:

Mysql –u root –p // "Then entering my password”

Here are the database settings in settings.py:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'djangostack',
    'HOST': 'localhost',
    'PORT': '3306',
    'USER': 'root',
    'PASSWORD': 'bitnami'
}
}

I've tried to restart MySQL server using sudo service mysqld restart but I recieve a message stating that mysql is an unrecognized service.

Here is the my.cnf file:

[mysqladmin]
user=root

[mysqld]
basedir=/opt/bitnami/mysql
datadir=/opt/bitnami/mysql/data
port=3306
socket=/opt/bitnami/mysql/tmp/mysql.sock
tmpdir=/opt/bitnami/mysql/tmp
bind-address=127.0.0.1

[mysqld_safe]
mysqld=mysqld.bin

[client]
port=3306
socket=/opt/bitnami/mysql/tmp/mysql.sock

[manager]
port=3306
socket=/opt/bitnami/mysql/tmp/mysql.sock
pid-file=/opt/bitnami/mysql/tmp/manager.pid
default-mysqld-path=/opt/bitnami/mysql/bin/mysqld.bin


!include /opt/bitnami/mysql/bitnami/my.cnf
share|improve this question
    
Try 127.0.0.1 instead of localhost. –  ceejayoz May 7 '13 at 15:24
    
@ceejayoz - Wow, that did it! Thanks! Why did that make such a big difference? –  fstephen07 May 7 '13 at 15:27

1 Answer 1

up vote 0 down vote accepted

Connect to the host 127.0.0.1 rather than localhost. localhost has special meaning for MySQL on a Unix based OS.

share|improve this answer
    
Fixed it! Thanks! –  fstephen07 May 7 '13 at 15:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.