-1

Can't connect to MySQL service. Below is the status output error I get when trying to start

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

ruan@master.danzlive.com:~$ systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) since Tue 2018-10-30 11:59:35 SAST; 1s ago
  Process: 1988 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 1998 (mysqld); Control PID: 1999 (mysql-systemd-s)
    Tasks: 16 (limit: 19660)
   Memory: 130.2M
      CPU: 577ms
   CGroup: /system.slice/mysql.service
           ├─1998 /usr/sbin/mysqld
           └─control
             ├─1999 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─2031 sleep 1

Oct 30 11:59:35 ip-197-101-38-62 systemd[1]: Starting MySQL Community Server...
ruan@master.danzlive.com:~$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
thepurpleowl
  • 147
  • 4
  • 15
  • is the mysql service running? – treyBake Oct 30 '18 at 10:10
  • Possible duplicate of [ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)](https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run) – Giorgos Myrianthous Oct 30 '18 at 10:16
  • The service is not running it won't start @GiorgosMyrianthous I have seen that thread and it didn't solve it for me – Ruan Conradie Oct 30 '18 at 10:40
  • 1
    Check the location of the mysqld.sock in the my.cnf file(s) - it might be in a server.cnf but it should be plain whereabouts it is. Make sure any client cnf also references the same mysqld.sock location – FreudianSlip Oct 30 '18 at 11:16

2 Answers2

1

I faced similar Issue in Ubuntu 18.04. I found the reason that - On last day I cleared Ubuntu using Stacer Application. This application removed mysql log folder at location

/var/log/

So next day while starting MySQL, got this error. I created that folder again and given permissions.

mkdir /var/log/mysql
sudo chown mysql:mysql -R /var/log/mysql
0

Try to add the database-username using the -u parameter directly via commandline.

mysql -u root <database>
Sven Rojek
  • 5,476
  • 2
  • 35
  • 57
Ali Ghaini
  • 882
  • 6
  • 13