django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")

Viewed 945

I've just moved my project which was running perfectly in windows to centos 7.

I've all the required dependencies installed in virtual environment and have mysql database running at http://localhost/phpmyadmin, using xampp.

however, python manage.py runserver throws me following error : django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")

also systemctl status mysqld throws following error

(myvenv) [root@CIPL-5PC226 django-project]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: deactivating (stop-sigterm) (Result: exit-code)
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 11595 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
  Process: 11572 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
    Tasks: 23
   CGroup: /system.slice/mysqld.service
           └─11598 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Jun 01 14:24:17 ABCD-5PC226 systemd[1]: Starting MySQL Server...
Jun 01 14:24:18 ABCD-5PC226 mysqld[11595]: Initialization of mysqld failed: 0
Jun 01 14:24:18 ABCD-5PC226 systemd[1]: mysqld.service: control process exited, code=exited status=1

because of my limited knowledge of centos, despite searching and trying out multiple solutions, I've not been able to resolve the issue yet.

my understanding is that i have sql running at localhost/xampp but due to some reason the project is not able to connect despite clearly mentioned in the database section of settings.py file of django project.

0 Answers
Related