Forums

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I know this is not a new topic but mySQL is not working. When I launch the site or use this command from shell I get an error:

mysql -u amarin -u amarin.mysql.pythonanywhere-services.com -p 'amarin$default' 
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

username, Database host address are what I have in the Database page, and from there I can start a console. The password should be correct. What am i doing wrong?

You've repeated -u instead of having -h for the host:

mysql -u amarin -h amarin.mysql.pythonanywhere-services.com -p 'amarin$default'

shouldn't one of the -u flags be -h?

Yes, I am sorry. I must have been tired. thank you

Glad we could help :-)

OperationalError at / (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") Request Method: GET Request URL: https://josewin056.pythonanywhere.com/ Django Version: 4.2.14 Exception Type: OperationalError Exception Value:
(2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") Exception Location: /home/Josewin056/.virtualenvs/travel/lib/python3.8/site-packages/MySQLdb/connections.py, line 195, in init Raised during: travelapp.views.demo Python Executable: /usr/local/bin/uwsgi Python Version: 3.8.10 Python Path:
['/var/www', '.', '', '/var/www', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/Josewin056/.virtualenvs/travel/lib/python3.8/site-packages', '//home/Josewin056/TravelProject/travelproject'] Server time: Thu, 11 Jul 2024 20:07:44 +0000

i get this type of error

You need to use the correct details to connect to your database. They are provided on your Databases page.

Nice information.

Thank you.

Glad we could help!