Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)") on ec2 bitnami?

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.

like image 463
Madhur Rampal Avatar asked Jan 30 '26 08:01

Madhur Rampal


2 Answers

Set the HOST to

127.0.0.1

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

like image 92
Madhur Rampal Avatar answered Feb 01 '26 22:02

Madhur Rampal


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

like image 31
gparis Avatar answered Feb 01 '26 23:02

gparis