2

I am working on ec2 bitnami with python django on AWS. I am encountering (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)") while fetching objects from mysql database.

I have been gone through so many forums still I am not getting what is it exactly and why this problem being arisen. Please tell me what is it and how to fix it for python django mysql on ec2 bitnami.

Thanks in advance.

Terry Seidler
  • 2,043
  • 15
  • 28
Madhur Rampal
  • 541
  • 3
  • 9
  • 21

2 Answers2

17

Set the HOST to

127.0.0.1

in settings.py and make sure MySQL server is running.

Maroun
  • 94,125
  • 30
  • 188
  • 241
Madhur Rampal
  • 541
  • 3
  • 9
  • 21
1

In a BitNami AMI the MySQL socket is /opt/bitnami/mysql/tmp/mysql.sock

Check the official BitNami documentation here: http://wiki.bitnami.org/Components/MySQL#What_is_the_default_configuration.3f

You should change the HOST setting accordingly in your settings file: https://docs.djangoproject.com/en/1.3/ref/settings/#host

gparis
  • 1,247
  • 12
  • 32
  • /installdir/mysql/tmp/mysql.sock is empty. What i have to write there? – Madhur Rampal Nov 16 '12 at 09:15
  • 1
    The MySQL socket should be in `/opt/bitnami/mysql/tmp/mysql.sock`. Otherwise, have you tried to set HOST to 127.0.0.1: `"HOST": '127.0.0.1'`? – gparis Nov 16 '12 at 10:02
  • I tried but again its showing error (2003, "Can't connect to MySQL server on '127.0.0.1' (111)") – Madhur Rampal Nov 16 '12 at 10:16
  • 1
    You should verify the MySQL server is up and running. Try also to set the HOST setting to localhost: `"HOST": 'localhost'`. – gparis Nov 16 '12 at 10:50
  • I tried "HOST": 'localhost' but again showing error (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)") – Madhur Rampal Nov 16 '12 at 11:11