0

I have tried a hundred of commands to fix this but to no avail.

I get this error when I try to run mysql service:

root@lander:/# systemctl status mariadb.service
● mariadb.service - MariaDB 10.1.45 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-09-26 21:39:19 CST; 9min ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 26857 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"
      CPU: 244ms

Sep 26 21:39:16 lander systemd[1]: Starting MariaDB 10.1.45 database server...
Sep 26 21:39:16 lander mysqld[26857]: 2020-09-26 21:39:16 140169480011136 [Note] /usr/sbin/mysqld (mysqld 10.1.45-MariaD
Sep 26 21:39:19 lander systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Sep 26 21:39:19 lander systemd[1]: Failed to start MariaDB 10.1.45 database server.
Sep 26 21:39:19 lander systemd[1]: mariadb.service: Unit entered failed state.
Sep 26 21:39:19 lander systemd[1]: mariadb.service: Failed with result 'exit-code'.

I think the main error is this, but couldn't handle it: MySQL -Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Linux version:

root@lander:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

MySql version:

root@lander:/# mysql --version
mysql  Ver 15.1 Distrib 10.1.45-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

EDIT I searched for the erroneous socket file because it doesn't exist in the path of the error:

root@lander:/# cd /var/run/mysqld
root@lander:/var/run/mysqld# ls
root@lander:/var/run/mysqld# cd ..
root@lander:/var/run# cd ..
root@lander:/var# cd ..
root@lander:/# find / -name 'mysqld.sock'
/var/lib/docker/overlay2/ab77f131581b7a77915ac3da0112d8fab3a6956f81f7f09b13fec07759bc3756/diff/run/mysqld/mysqld.sock
/var/lib/docker/overlay2/ab77f131581b7a77915ac3da0112d8fab3a6956f81f7f09b13fec07759bc3756/merged/run/mysqld/mysqld.sock
/var/lib/docker/overlay2/ef28c7d5507d3b888ceaf8e79b53a865e16c10c5bea46789e138ac2ff562195f/diff/run/mysqld/mysqld.sock
/var/lib/docker/overlay2/ef28c7d5507d3b888ceaf8e79b53a865e16c10c5bea46789e138ac2ff562195f/merged/run/mysqld/mysqld.sock
root@lander:/#    

EDIT2

content of /etc/mysql/my.cnf

# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

EDIT3

Journal logs "journalctl -u mysql":

root@lander:/# journalctl -u mysql
-- Logs begin at Wed 2019-07-10 18:31:14 CST, end at Sat 2020-09-26 22:48:51 CST. --
Sep 24 18:36:07 lander systemd[1]: Starting MySQL Community Server...
Sep 24 18:36:07 lander su[2785]: Successful su for mysql by root
Sep 24 18:36:07 lander su[2785]: + ??? root:mysql
Sep 24 18:36:07 lander su[2785]: pam_unix(su:session): session opened for user mysql by (uid=0)
Sep 24 18:36:07 lander mysql-systemd-start[2750]: 2020-09-24T10:36:07.857850Z 0 [Warning] TIMESTAMP with implicit DEFAUL
Sep 24 18:36:07 lander mysql-systemd-start[2750]: 2020-09-24T10:36:07.859745Z 0 [ERROR] --initialize specified but the d
Sep 24 18:36:07 lander mysql-systemd-start[2750]: 2020-09-24T10:36:07.860817Z 0 [ERROR] Aborting
Sep 24 18:36:10 lander systemd[1]: mysql.service: Control process exited, code=exited status=1
Sep 24 18:36:10 lander systemd[1]: Failed to start MySQL Community Server.
Sep 24 18:36:10 lander systemd[1]: mysql.service: Unit entered failed state.
Sep 24 18:36:10 lander systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 24 18:36:10 lander systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 24 18:36:10 lander systemd[1]: Stopped MySQL Community Server.
Sep 24 18:36:10 lander systemd[1]: Starting MySQL Community Server...
Sep 24 18:36:10 lander su[2898]: Successful su for mysql by root
Sep 24 18:36:10 lander su[2898]: + ??? root:mysql
Sep 24 18:36:10 lander su[2898]: pam_unix(su:session): session opened for user mysql by (uid=0)
Sep 24 18:36:10 lander mysql-systemd-start[2863]: 2020-09-24T10:36:10.550368Z 0 [Warning] TIMESTAMP with implicit DEFAUL
Sep 24 18:36:10 lander mysql-systemd-start[2863]: 2020-09-24T10:36:10.551842Z 0 [ERROR] --initialize specified but the d
Sep 24 18:36:10 lander mysql-systemd-start[2863]: 2020-09-24T10:36:10.552828Z 0 [ERROR] Aborting
Sep 24 18:36:12 lander systemd[1]: mysql.service: Control process exited, code=exited status=1
Sep 24 18:36:12 lander systemd[1]: Failed to start MySQL Community Server.
Sep 24 18:36:12 lander systemd[1]: mysql.service: Unit entered failed state.
Sep 24 18:36:12 lander systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 24 18:36:12 lander systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 24 18:36:12 lander systemd[1]: Stopped MySQL Community Server.
Sep 24 18:36:12 lander systemd[1]: Starting MySQL Community Server...
Sep 24 18:36:12 lander su[2986]: Successful su for mysql by root
Sep 24 18:36:12 lander su[2986]: + ??? root:mysql
Sep 24 18:36:12 lander su[2986]: pam_unix(su:session): session opened for user mysql by (uid=0)
Sep 24 18:36:12 lander mysql-systemd-start[2951]: 2020-09-24T10:36:12.782020Z 0 [Warning] TIMESTAMP with implicit DEFAUL
Sep 24 18:36:12 lander mysql-systemd-start[2951]: 2020-09-24T10:36:12.783822Z 0 [ERROR] --initialize specified but the d
Sep 24 18:36:12 lander mysql-systemd-start[2951]: 2020-09-24T10:36:12.785301Z 0 [ERROR] Aborting
Sep 24 18:36:14 lander systemd[1]: mysql.service: Control process exited, code=exited status=1
Sep 24 18:36:14 lander systemd[1]: Failed to start MySQL Community Server.
Sep 24 18:36:14 lander systemd[1]: mysql.service: Unit entered failed state.
Sep 24 18:36:14 lander systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 24 18:36:14 lander systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 24 18:36:14 lander systemd[1]: Stopped MySQL Community Server.
Sep 24 18:36:14 lander systemd[1]: Starting MySQL Community Server...
Sep 24 18:36:14 lander su[3074]: Successful su for mysql by root
Sep 24 18:36:14 lander su[3074]: + ??? root:mysql
Abeer Sul
  • 101
  • 4
  • 1
    does your socket file at /var/run/mysqld/mysqld.sock exist? Because the socket file might be created in another location. You can search for the mysql socket file with find / -name 'mysqld.sock'. – Lorem ipsum Sep 26 '20 at 14:15
  • @LukasRäpple thanks, no it doesn't and I have edited the question with find result – Abeer Sul Sep 26 '20 at 14:21
  • 1
    Is the MySQL running inside docker? Also check what is the value for the "socket" directive inside my.cnf – Lorem ipsum Sep 26 '20 at 14:25
  • how do I know? I tried now to stop all running docker containers as I don't need them now on this server (used long time ago). I also posted the contents of my.cnf – Abeer Sul Sep 26 '20 at 14:34
  • 1
    Well your edit isn't that useful because the relevant configurations seem to be inside the included directories. The thing im trying to check is if their is a misconfiguration and mysql creates the socket file in another location as /var/run/mysqld/mysqld.sock. So inside the mysql configuration directories there is usually a "socket" directive which specifies the socket path. But if there is no socket file created by mysql in the whole filesystem, this error is maybe just a symptom of mysql being unable to start. – Lorem ipsum Sep 26 '20 at 14:43
  • @LukasRäpple, makes sense. I was thinking something similar. I found an empty " /run/systemd/journal/socket" that's it. what can I do now? – Abeer Sul Sep 26 '20 at 14:47
  • 1
    If you retart mysqld what is the mysql log telling you? Or "journalctl -u mysql" – Lorem ipsum Sep 26 '20 at 14:49
  • I posted the output. Now its working after " /etc/init.d/mysql start" !!! @LukasRäpple What do you think was the cause??? – Abeer Sul Sep 26 '20 at 14:53
  • Well your MySQL service wasn't started obviously. But would be interesting if it also works with systemctl start MySQL. Of course after stopping mysqld first with init. – Lorem ipsum Sep 26 '20 at 14:56
  • No, "systemctl start MySQL" didn't do it. "/etc/init.d/mysql start" only works. But basically this command never worked earlier. Maybe after I stopped all docker containers after your comment, it fixed something.. – Abeer Sul Sep 26 '20 at 14:59
  • Please show the rest of the error messages. You have cut off part of them. – Michael Hampton Sep 26 '20 at 17:06

1 Answers1

0

Based on Lukas Räpple's comments, I attempted to stop all docker containers

docker stop $(docker ps -aq)

Then I removed the because I didn't need them

 docker rm $(docker ps -aq)

Which probably was the reason mysql wasn't able to start via

/etc/init.d/mysql start

After that it worked without issues.

Abeer Sul
  • 101
  • 4