2

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
2
  • Try 127.0.0.1 instead of localhost.
    – ceejayoz
    May 7, 2013 at 15:24
  • @ceejayoz - Wow, that did it! Thanks! Why did that make such a big difference? May 7, 2013 at 15:27

1 Answer 1

3

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .