Error establishing a connection to the database

Websites that have databases get this error:
Error establishing a connection to the database

Can you help me please.

systemctl status mysql
or systemctl status mariadb

1 Like

× mariadb.service - MariaDB 10.11.11 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: failed (Result: exit-code) since Thu 2025-02-06 10:49:41 -03; 2min 41s ago
Duration: 1month 4w 1h 21min 59.973s
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 722863 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 722864 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 722867 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=/usr/bin/galera_recovery; [ $? -eq 0 ] && sys>
Process: 722926 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=7)
Main PID: 722926 (code=exited, status=7)
Status: “MariaDB server is down”
CPU: 172ms

Feb 06 10:49:41 servpc.cl mariadbd[722926]: 2025-02-06 10:49:41 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Feb 06 10:49:41 servpc.cl mariadbd[722926]: 2025-02-06 10:49:41 0 [ERROR] /usr/sbin/mariadbd: unknown variable 'provider_bzip2=force_plus_perman>
Feb 06 10:49:41 servpc.cl mariadbd[722926]: 2025-02-06 10:49:41 0 [ERROR] /usr/sbin/mariadbd: unknown variable 'provider_lz4=force_plus_permanen>
Feb 06 10:49:41 servpc.cl mariadbd[722926]: 2025-02-06 10:49:41 0 [ERROR] /usr/sbin/mariadbd: unknown variable 'provider_lzma=force_plus_permane>
Feb 06 10:49:41 servpc.cl mariadbd[722926]: 2025-02-06 10:49:41 0 [ERROR] /usr/sbin/mariadbd: unknown variable 'provider_lzo=force_plus_permanen>
Feb 06 10:49:41 servpc.cl mariadbd[722926]: 2025-02-06 10:49:41 0 [ERROR] /usr/sbin/mariadbd: unknown variable 'provider_snappy=force_plus_perma>
Feb 06 10:49:41 servpc.cl mariadbd[722926]: 2025-02-06 10:49:41 0 [ERROR] Aborting
Feb 06 10:49:41 servpc.cl systemd[1]: mariadb.service: Main process exited, code=exited, status=7/NOTRUNNING
Feb 06 10:49:41 servpc.cl systemd[1]: mariadb.service: Failed with result ‘exit-code’.
Feb 06 10:49:41 servpc.cl systemd[1]: Failed to start mariadb.service - MariaDB 10.11.11 database server.

Please make sure you don’t downgrade the current mariadb version

Make sure you don’t downgrade the current version of mariadb
What do I do?

This email is arriving:
Can’t connect to MySQL localhost:3306
ERROR 2002 (HY000): Can’t connect to local server through socket ‘/run/mysqld/mysqld.sock’ (2)

Can I reinstall?
sudo apt reinstall mysql-server

Solucionado

You need to check, why your mysql server isnt running. Also please be informed, that we expect you to be able to read and understand log files. We cant provide step by step guides, how you would do so.

If you can’t solve it, please get help from a sysadmin which can check your system.