Mysqld.sock can't connect

I’m having this error:

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

When I try to locate /run/mysqld/mysqld.sock, it threw a No such file or directory

Is there a way to fix this?

Is mysqld service running?
systemctl status mysqld.service

to start it
sudo systemctl start mysqld.service

to stop it
sudo systemctl stop mysqld.service

to enable it at each boot or system startup
sudo systemctl enable mysqld.service

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

I got this error:

● mariadb.service - MariaDB 10.5.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Sat 2020-09-05 22:41:27 PST; 11h ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 1422 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 1423 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START>
    Process: 1432 ExecStart=/usr/bin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
   Main PID: 1432 (code=exited, status=1/FAILURE)
     Status: "MariaDB server is down"

Sep 05 22:41:27 user mariadbd[1432]: 2020-09-05 22:41:27 0 [ERROR] InnoDB: Upgrade after a crash is not supported. The redo log was created with MariaDB 10.4.6.
Sep 05 22:41:27 user mariadbd[1432]: 2020-09-05 22:41:27 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
Sep 05 22:41:27 user mariadbd[1432]: 2020-09-05 22:41:27 0 [Note] InnoDB: Starting shutdown...
Sep 05 22:41:27 user mariadbd[1432]: 2020-09-05 22:41:27 0 [ERROR] Plugin 'InnoDB' init function returned error.
Sep 05 22:41:27 user mariadbd[1432]: 2020-09-05 22:41:27 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Sep 05 22:41:27 user mariadbd[1432]: 2020-09-05 22:41:27 0 [ERROR] Unknown/unsupported storage engine: InnoDB
Sep 05 22:41:27 user mariadbd[1432]: 2020-09-05 22:41:27 0 [ERROR] Aborting
Sep 05 22:41:27 user systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Sep 05 22:41:27 user systemd[1]: mariadb.service: Failed with result 'exit-code'.
Sep 05 22:41:27 user systemd[1]: Failed to start MariaDB 10.5.5 database server.

There are some steps to follow after installation of mariadb package, see
https://wiki.archlinux.org/index.php/MariaDB#Installation

I’ve been using this for a while now and I haven’t encountered any problems until I updated the system.

Apparently the previously running mariadb version crashed and left a redo log.
Meanwhile you did the update to 10.5.5 and this is not supported (by mariadb).

Oh, is it okay to downgrade mariadb?

You can try it. But it is easier to start fresh and restore the DB(s) form your backup.

1 Like

Where are the backup data located?

The place you choose to store your backup.

This is not done automatically, you are responsible to backup important data.

2 Likes

Are there any data in /var/lib/mysql or any folder/data that needs to backup?

That’s the default directory where all databases get stored - not a backup.
Did you have any databases with data you want to keep?
If you don’t have a backup you might want to try to load the pertitant databases via 10.4.6 mariadb - whether it’s by downgrading on manjaro or using any other distribution (or container) with an older mariadb.

I tried downgrading mariadb, but I got an error:

> DOWNGRADE_FROM_ALA=1 downgrade mariadb

warning: downgrading package mariadb (10.5.5-2 => 10.4.6-1)
resolving dependencies...
warning: cannot resolve "mariadb-clients=10.4.6", a dependency of "mariadb"
:: The following package cannot be upgraded due to unresolvable dependencies:
      mariadb

:: Do you want to skip the above package for this upgrade? [y/N] n
error: failed to prepare transaction (could not satisfy dependencies)
:: unable to satisfy dependency 'mariadb-clients=10.4.6' required by mariadb
> DOWNGRADE_FROM_ALA=1 downgrade mariadb-clients

warning: downgrading package mariadb-clients (10.5.5-2 => 10.4.6-1)
resolving dependencies...
warning: cannot resolve "mariadb-libs=10.4.6", a dependency of "mariadb-clients"
:: The following package cannot be upgraded due to unresolvable dependencies:
      mariadb-clients

:: Do you want to skip the above package for this upgrade? [y/N] n
error: failed to prepare transaction (could not satisfy dependencies)
:: unable to satisfy dependency 'mariadb-libs=10.4.6' required by mariadb-clients

You’re already on the right path: all dependencies must be fullfilled, so mariadb-libs must be downgraded as well.

I have the same problem, but different :thinking:

For starters I’m getting the same error message:

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

systemctl status mysqld.service tells me:

● mariadb.service
     Loaded: bad-setting (Reason: Unit mariadb.service has a bad unit file setting.)
     Active: inactive (dead)

Okt 15 15:33:56 puck systemd[1]: /etc/systemd/system/mariadb.service:1: Assignment outside of section. Ignoring.
Okt 15 15:33:56 puck systemd[1]: /etc/systemd/system/mariadb.service:4: Assignment outside of section. Ignoring.

when I look into mariadb.service:

.include /usr/lib/systemd/system/mariadb.service

# dont protect home
ProtectHome=false

I don’t seem to find anything strange in there either…

Does anyone have an idea as to how I could fix this?

best
Daniel

This is not a valid systemd unit file.

Did you created this file yourself? Please delete it or fix it. If you want to make a change/add something to a existent unit file, use an override service file.
It can be created by

systemctl edit mariadb.service

Make sure you delete your own mariadb.service file in /etc/systemd/system/ first.

You can also use the .include line, but other options need to be in a valid section. Please note that the .include is an ancient way, not document and might stop working at any time in the future.

thanks a lot xabbu,
removing the file worked perfectly.

have a very nice day!

best
daniel