Unable to start mariadb service

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) 7
  • mariadb

Issue

  • Failed to start mariadb service.
[root@workstation ~]# systemctl status mariadb -l
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-02-14 02:13:33 EST; 3min 38s ago
  Process: 5773 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 5772 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 5742 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 5772 (code=exited, status=0/SUCCESS)

Feb 14 02:13:27 workstation.lab.example.com systemd[1]: Stopped MariaDB database server.
Feb 14 02:13:27 workstation.lab.example.com systemd[1]: Starting MariaDB database server...
Feb 14 02:13:27 workstation.lab.example.com mariadb-prepare-db-dir[5742]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Feb 14 02:13:27 workstation.lab.example.com mysqld_safe[5772]: 190214 02:13:27 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Feb 14 02:13:27 workstation.lab.example.com mysqld_safe[5772]: 190214 02:13:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Feb 14 02:13:33 workstation.lab.example.com systemd[1]: mariadb.service: control process exited, code=exited status=1
Feb 14 02:13:33 workstation.lab.example.com systemd[1]: Failed to start MariaDB database server.
Feb 14 02:13:33 workstation.lab.example.com systemd[1]: Unit mariadb.service entered failed state.
Feb 14 02:13:33 workstation.lab.example.com systemd[1]: mariadb.service failed.
[root@workstation ~]# 

Resolution

  • As per the logs in the /var/log/mariadb/mariadb.log, /mysql-bin.000044 file was misplaced to some other location.
190213 13:15:02 [ERROR] mysqld: File './mysql-bin.000044' not found (Errcode: 2)
190213 13:15:02 [ERROR] Failed to open log (file './mysql-bin.000044', errno 2)
190213 13:15:02 [ERROR] Could not open log file
  • Locate the file /mysql-bin.000044 and move it back to the original location /var/lib/mysql
[root@workstation ~]# ls /var/lib/mysql/mysql-bin.index 
[root@workstation ~]# find / -name mysql-bin.000009
  • Restart the mariadb service.
[root@workstation ~]# systemctl restart mariadb 

Diagnostic Steps

  • Check status of mariadb service.
[root@workstation ~]# systemctl status mariadb -l
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-02-14 02:13:33 EST; 3min 38s ago
  Process: 5773 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 5772 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 5742 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 5772 (code=exited, status=0/SUCCESS)

Feb 14 02:13:27 workstation.lab.example.com systemd[1]: Stopped MariaDB database server.
Feb 14 02:13:27 workstation.lab.example.com systemd[1]: Starting MariaDB database server...
Feb 14 02:13:27 workstation.lab.example.com mariadb-prepare-db-dir[5742]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Feb 14 02:13:27 workstation.lab.example.com mysqld_safe[5772]: 190214 02:13:27 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Feb 14 02:13:27 workstation.lab.example.com mysqld_safe[5772]: 190214 02:13:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Feb 14 02:13:33 workstation.lab.example.com systemd[1]: mariadb.service: control process exited, code=exited status=1
Feb 14 02:13:33 workstation.lab.example.com systemd[1]: Failed to start MariaDB database server.
Feb 14 02:13:33 workstation.lab.example.com systemd[1]: Unit mariadb.service entered failed state.
Feb 14 02:13:33 workstation.lab.example.com systemd[1]: mariadb.service failed.
[root@workstation ~]# 
  • Check /var/log/mariadb/mariadb.log for errors.
190213 13:15:01 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
190213 13:15:01 [Note] /usr/libexec/mysqld (mysqld 5.5.60-MariaDB) starting as process 25896 ...
190213 13:15:01 InnoDB: The InnoDB memory heap is disabled
190213 13:15:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins
190213 13:15:01 InnoDB: Compressed tables use zlib 1.2.7
190213 13:15:01 InnoDB: Using Linux native AIO
190213 13:15:01 InnoDB: Initializing buffer pool, size = 128.0M
190213 13:15:01 InnoDB: Completed initialization of buffer pool
190213 13:15:01 InnoDB: highest supported file format is Barracuda.
190213 13:15:01  InnoDB: Waiting for the background threads to start
190213 13:15:02 example exampleDB (http://www.example.com) 5.5.59-MariaDB-38.11 started; log sequence number 21641416987
190213 13:15:02 [Note] Plugin 'FEEDBACK' is disabled.
190213 13:15:02 [ERROR] mysqld: File './mysql-bin.000044' not found (Errcode: 2)
190213 13:15:02 [ERROR] Failed to open log (file './mysql-bin.000044', errno 2)
190213 13:15:02 [ERROR] Could not open log file
190213 13:15:02 [ERROR] Can't init tc log
190213 13:15:02 [ERROR] Aborting

190213 13:15:02  InnoDB: Starting shutdown...
190213 13:15:07  InnoDB: Shutdown completed; log sequence number 21641416987
190213 13:15:07 [Note] /usr/libexec/mysqld: Shutdown complete

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.