• Register
1 vote
32 views

Problem :

I am very new to MySQL Server. I am newly assigned to this MySQL Server project. If I try to connect with the local MySQL server during my assigned test suite it shows me the below error:

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

But still I can connect to the MySQL by running a command line MySQL program. The following command ps aux | grep mysql informs that my server is running also the below command stat /tmp/mysql.sock validate that my socket exists. Additionally if I try to open my debugger in except clause related to that exception I can connect with my exact same parameters.

I am very confused about above error. Can some expert help me in fixing it?

8 5 2
3,230 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution :

I know such errors are very annoying. I had faced this error earlier and was able to fix it.

The below command helped me.

sudo /usr/local/mysql/support-files/mysql.server start

If above command does not work for you then you need to make sure that the mysqld is running and then you can try connecting it again.

If still not working then you can try below process.

At your terminal you need to run below command

mysql_config –socket
Above command will provide you with your path to the sock file. You need to take that path and then you can use it in your DATABASES HOST paramater.

You need to do below in your DATABASES HOST parameter:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'test',
        'USER': 'test',
        'PASSWORD': 'test',
        'HOST': '/Applications/MAMP/tmp/mysql/mysql.sock',
        'PORT': '',
    },
}

It will surely fix the problem.

8 4
5,680 points

Related questions

0 votes
1 answer 83 views
83 views
Problem : My problem kicked off when I was unable to log in as the root any more on the mysql install. I was trying to run mysql without the passwords turned on however when I ran my below command : # mysqld_safe --skip-grant-tables & I never got my prompt back. ... socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
asked Jan 4, 2020 alecxe 7.5k points
0 votes
1 answer 44 views
44 views
Problem : My problem started with me when I was unable to log in as root any more on the mysql install. I was trying to run mysql without passwords turned on... but whenever I ran the below command # mysqld_safe --skip-grant-tables & I would never get my prompt back ... socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
asked Dec 27, 2019 alecxe 7.5k points
0 votes
2 answers 141 views
141 views
I want to run a Django application in PyCharm which works on MySQL DB. I am unable to connect my program to the database. When I am trying to install MySQLclient or MySQL-python I am getting the error: Failed building wheel for MySQLclient Please help me out in connecting my Django program with MySQL database.
asked Oct 24, 2020 psandprop 2.4k points
0 votes
1 answer 302 views
302 views
Problem : I am not very sure how can I fix the below issue I have really no idea about why am I facing below error while trying to do the runserver: Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread ... server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
asked Dec 25, 2019 alecxe 7.5k points
0 votes
1 answer 270 views
270 views
Problem : I am trying to develop some selenium tests which should run with headless firefox but the following error suddenly popped up in my server.log file when I was trying to connect to the webdriver via following command: driver = webdriver.Firefox(firefox_profile = profile, log_path = ... spec as below: python 2.7.12, Firefox: Mozilla Firefox 57.0.3, geckodriver: 0.19.1, selenium: 3.8.0
asked Dec 3, 2019 alecxe 7.5k points
0 votes
1 answer 1.7K views
1.7K views
I was creating a new project in django. Firstly I installed django in my system but when I run the command : python manage.py runserver It does not work It shows a message : python: can't open file 'manage.py': [Errno 2] No such file or directory ... django and I started a project by running the command : django-admin startproject Utility Why am I seeing this error message, do anyone know?
asked Mar 18, 2020 LizzyM 6.1k points
0 votes
1 answer 2 views
2 views
mengatasi can't connect to mysql server on 'localhost' (10061)
asked Feb 16 ArifulIslam 7.5k points
0 votes
1 answer 13 views
13 views
Problem: failed to connect to mysql at 127.0.0.1:3306 with user root.
asked Feb 16 charles mathews 3.8k points
0 votes
1 answer 44 views
44 views
Problem : I am new to WampServer and while trying to install the Joomla 3.3.4 on my localhost in a Database Configuration I have encountered below error “Could not connect to the database. Connector returned number: Could not connect to MySQL." I also tried to leave the password as blank, but still it didn’t connect.
asked Feb 18, 2020 mphil 2.3k points
0 votes
1 answer 17 views
17 views
This is the error I get (mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python Downloading/unpacking mysql-python Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded Running setup.py egg_info for package mysql-python sh: mysql_config: not found ... egg_info failed with error code 1 Storing complete log in /home/zjm1126/.pip/pip.log What can I do to resolve this?
asked Oct 24, 2020 psandprop 2.4k points