0

I just installed MariaDB from the debian repo and I can't start it.

root@Debian9A1:~$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/var/run/mysqld/mysqld.sock' (2)

I tried to launch the service, no success :

root@Debian9A1:/var/log/mysql# systemctl start mariadb
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.

Service status is not useful :

root@Debian9A1:/var/log/mysql# systemctl status mariadb.service
● mariadb.service - MariaDB 10.3.15 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-07-22 16:28:51 CEST; 24s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 3987 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exit

juil. 22 16:28:51 Debian9A1 systemd[1]: Starting MariaDB 10.3.15 database server...
juil. 22 16:28:51 Debian9A1 systemd[1]: mariadb.service: Control process exited, code=exited status
juil. 22 16:28:51 Debian9A1 systemd[1]: Failed to start MariaDB 10.3.15 database server.
juil. 22 16:28:51 Debian9A1 systemd[1]: mariadb.service: Unit entered failed state.
juil. 22 16:28:51 Debian9A1 systemd[1]: mariadb.service: Failed with result 'exit-code'.

Neither is journalctl :

root@Debian9A1:/var/log/mysql# journalctl -xe
[...]
juil. 22 16:28:51 Debian9A1 systemd[1]: Starting MariaDB 10.3.15 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a commencé à démarrer.
juil. 22 16:28:51 Debian9A1 systemd[1]: mariadb.service: Control process exited, code=exited status=127
juil. 22 16:28:51 Debian9A1 systemd[1]: Failed to start MariaDB 10.3.15 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
juil. 22 16:28:51 Debian9A1 systemd[1]: mariadb.service: Unit entered failed state.
juil. 22 16:28:51 Debian9A1 systemd[1]: mariadb.service: Failed with result 'exit-code'.

Finally, I don't have anything in the file /var/log/mysql/error.log

Do you have any ideas to help me troubleshoot the problem ? I already tried to reinstall all packages with :

apt-get --purge remove "mysql*"
apt-get --purge remove "mariadb*"

It was not helpful

xenom
  • 31
  • 1
  • 1
  • 4

4 Answers4

2

Please execute:

service mariadb restart; journalctl -xe

So you can ensure no other messages will push mysql/mariadb output outside the view of -xe.

Maybe database never got initialized.

So it might help to know the content of /etc/my.cnf.

let uns know, where datadir is located.

datadir    = /var/lib/mysql

But afaik it changes in some distribution and version to /var/lib/mariadb

If datadir is set and, very important: data dir is empty and database no running:

execute mysql_install_db manually.

** Maybe datadir must be changed.

chown -R mysql:mysql /var/lib/mysql

then try it again:

service mariadb start; journalctl -xe

Maybe use this as initial my.cnf

    # This is default example of MySQL/MariaDB configuration provided with openSUSE package
# It is based on upstream defaults with some additional examples.


# The following options will be passed to all MariaDB clients
[client]
# password  = your_password
# port       = 3306
# socket     = /var/run/mysql/mysql.sock

[xtrabackup]
target_dir = /DATA/BACKUP/mysql
datadir = /var/lib/mysql/

[mysqld]
socket                          = /var/lib/mysql/mysql.sock
innodb_buffer_pool_size         = 20G
innodb_file_format              = Barracuda
innodb_file_per_table           = ON
innodb_buffer_pool_instances    = 20
innodb_thread_concurrency       = 4
innodb_purge_threads            = 4
innodb_strict_mode              = 1
innodb_old_blocks_time          = 1000
innodb_stats_on_metadata        = 0
innodb_write_io_threads         = 4
innodb_read_io_threads          = 4
innodb_io_capacity              = 200000
innodb_open_files               = 10000
innodb_log_file_size            = 1G
innodb_log_buffer_size          = 1G
innodb_log_files_in_group       = 3
transaction-isolation           = READ-COMMITTED


server-id                       = 1
#skip-networking
bind-address                   = 0.0.0.0

log_bin                        = master-mysql-bin
back_log                       = 500
concurrent_insert              = ALWAYS
expire_logs_days               = 10
delay-key-write                = ALL
myisam-recover-options         = FORCE,BACKUP
key_buffer_size                = 512M
join_buffer_size               = 256M
max_allowed_packet             = 128M
max_heap_table_size            = 1024M
tmp_table_size                 = 1024M
thread_stack                   = 192K
table_open_cache               = 10240
table_definition_cache         = 10240
open_files_limit               = 100000
net_retry_count                = 16384
query_cache_type               = 0
query_cache_size               = 0M
query_cache_limit              = 0M
query_cache_min_res_unit       = 1K
thread_cache_size              = 100
max_connections                = 100
ft_max_word_len                = 20
ft_min_word_len                = 3
long_query_time                = 5
local-infile                   = 0
log-warnings                   = 2
performance_schema             = ON
log-slave-updates
log-queries-not-using-indexes
skip-external-locking
skip-symbolic-links
skip-name-resolve

!includedir /etc/my.cnf.d

And then start mysql / mariadb manually:

# To ensure the service is stoppen:
service mariadb stop

/usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=mysql
MWE
  • 19
  • 5
  • journalctl -xe was described in my first post, it gives absolutely nothing interesting except "it failed".. my.cnf is nearly empty and indicates only other conf directory. I tried to reinstall the db and change the permissions without success. I am so upset not being able to get any clue from the error message or the logs. – xenom Jul 24 '19 at 15:24
  • 1
    Maybe this article will help you in the first steps: https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/ – MWE Jul 25 '19 at 07:34
  • @xenom, did it work? – MWE Jul 26 '19 at 08:04
  • Thanks, it was `chown -R mysql:mysql /var/lib/mysql` that did it for me. – phocks Dec 27 '21 at 22:11
0

I think you could have a permission issue on the datadir or you have still have multiple versions of mariadb runnning.

  1. Could you post your datadir permissions ?
  2. And also output of the debian equivalent of rpm -qa|grep -i maria . I think its something like

    apt-list --installed| grep -i maria
    dpkg -l | grep -i maria

MarcoZen
  • 189
  • 1
  • 5
0

In my case, the problem was in my.cnf (Centos 7)

  1. find / -name my.cnf backup and delete them all sudo cp /etc/my.cnf ~/mysql_bkp/my.cnf sudo rm -r /etc/my.cnf sudo cp /etc/mysql/my.cnf ~/mysql_bkp/mysql/my.cnf sudo rm -r /etc/mysql/my.cnf
  2. Delete all mysql dirs sudo rm -r /etc/mysql sudo rm -r /var/lib/mysql
  3. Reistall MariaDB sudo yum erase mariadb sudo yum install mariadb
  4. Start MariaDB systemctl start mariadb
  5. Goal!
-1
sudo apt install mysql-common
sudo service mysql start
service mysql status

This worked for me

  • 1
    Please explain what your steps do to the system, and why they help. In this case, the OP has already installed. – SamErde Jun 01 '21 at 14:33