DBI connect failed : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

Hey guys,

The MySQL crashed during the night and I can’t retart MySQL now. I don’t know what happens… I tried to connect to my Wordpress dashboard this morning and it doesn’t work anymore. All of 10 websites are down so it’s not a WP issue.

Any thoughts?

I can’t find any mysql.sock but I see mysqld.sock in /var/run/mysqld or /run/mysqld (is this the same folder?).

Well… why I don’t have a mysql.sock now?

In /etc/mysql I have a my.cnf with that content:

#
[client-server]

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

Is it normal?

Yes, restarting MySQL service.

Q: How to restart MySQL service on CentOS 7

hum yeah this is the first thing I made and this is why I have this error. It doesn’t work. Even in command line. And it takes a very long time to load when I try to restart the mysql service.

What are the systemctl status mysqld and journalctl -xe outputs?

I tried to add the line:

socket = /var/run/mysqld/mysqld.sock

in my.cnf but same thing, except the error code is not (111) but (2) now.

Here are the results of the command:

● mariadb.service - MariaDB 10.3.22 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: deactivating (final-sigterm) (Result: exit-code) since Fri 2020-06-26 07:19:37 UTC; 10h ago
Docs: man:mysqld(8)
systemd - MariaDB Knowledge Base
Process: 5287 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 5290 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 5292 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=/usr/bin/galera_recovery; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || ex
Process: 5367 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Main PID: 5367 (code=exited, status=1/FAILURE)
Status: “MariaDB server is down
Tasks: 3 (limit: 4604)
Memory: 25.0M
CGroup: /system.slice/mariadb.service
└─18283 /usr/sbin/mysqld

Jun 26 17:11:52 vps-6b2ce37c systemd[1]: Starting MariaDB 10.3.22 database server…
Jun 26 17:11:52 vps-6b2ce37c systemd[1]: mariadb.service: Found left-over process 18283 (mysqld) in control group while starting unit. Ignoring.
Jun 26 17:11:52 vps-6b2ce37c systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Jun 26 17:11:53 vps-6b2ce37c mysqld[5367]: 2020-06-26 17:11:53 0 [Note] /usr/sbin/mysqld (mysqld 10.3.22-MariaDB-0+deb10u1) starting as process 5367 …
Jun 26 17:12:26 vps-6b2ce37c systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jun 26 17:27:26 vps-6b2ce37c systemd[1]: mariadb.service: State ‘stop-sigterm’ timed out. Skipping SIGKILL.

and a lot of lines like these one:

postfix/smtpd[7143]: disconnect from unknown[185.143.75.153] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
postfix/smtpd[3326]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory
postfix/smtpd[3326]: warning: unknown[185.143.75.81]: SASL LOGIN authentication failed: generic failure
postfix/smtpd[16653]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory
postfix/smtpd[16653]: warning: unknown[212.70.149.34]: SASL LOGIN authentication failed: generic failure
postfix/smtpd[8319]: connect from unknown[46.38.145.6]
postfix/smtpd[11534]: connect from unknown[46.38.150.37]
postfix/smtpd[3326]: disconnect from unknown[185.143.75.81] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
postfix/smtpd[16653]: disconnect from unknown[212.70.149.34] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
postfix/smtpd[8322]: connect from unknown[46.38.148.2]
postfix/smtpd[16869]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory
postfix/smtpd[16869]: warning: unknown[46.38.145.254]: SASL LOGIN authentication failed: generic failure
postfix/smtpd[16869]: disconnect from unknown[46.38.145.254] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
postfix/smtpd[16653]: connect from unknown[46.38.148.6]
postfix/smtpd[2901]: connect from unknown[46.38.150.47]

I also read that on another group:

Someone has removed the Unix socket file that mysqld uses (/tmp/mysql.sock by default). For example, you might have a cron job that removes old files from the /tmp directory. You can always run mysqladmin version to check whether the Unix socket file that mysqladmin is trying to use really exists. The fix in this case is to change the cron job to not remove mysql.sock or to place the socket file somewhere else. See Section B.5.4.5, “How to Protect or Change the MySQL Unix Socket File”.

But why the mysql.socket would be in the /tmp folder instead of another one? I don’t know where I can find the cron jobs to see if one of them could be related with that.

warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory

Restart saslauthd service by running:

systemctl restart saslauthd

Check for the out put of:

lsof /var/run/mysqld/mysqld.sock

mariadb.service: Found left-over process 18283 (mysqld) in control group while starting unit. Ignoring.

Check on this process as well.


I would simply check configuration file(s) for MariaDB and its socket directive and made sure that the path is accessible (has correct permissions) and actually exists.

As an extra measure try rebooting your server.

Note: You might face this issue again in the future, and I assume the solution would be is to increase RAM or re-configure your services accordingly -

https://www.virtualmin.com/documentation/system/low-memory

1 Like

Resources and memory are good and this morning I already reboot webmin (maybe I can try to reboot my VPS).

I enter the command

lsof /var/run/mysqld/mysqld.sock

but nothing special… even to restart saslauthd.service

It works now after the reboot of the VPS. Pretty weird. I don’t know why the restart of Webmin didn’t change anything, but the reboot of VPS solved the issue. I don’t understand… but glad it works now.

Thanks for the suggestion @Ilia ! I spent my day on that just for a simple reboot -_-

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.