-3

I have MySQL server installed on a CentOS 7. However, I stopped it once and now I can't restart it because I get this error:

Failed to start database :

Redirecting to /bin/systemctl start  mariadb.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 have worked with MySQL for many years now but this is a new server I am moving to and I have never heard about MariaDB so I have no idea what it is. Can you please help me fix this error?

Thank you.


FULL ERROR LOG

â— mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2017-03-17 13:48:21 EDT; 2min 13s ago
  Process: 10775 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 10774 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=1/FAILURE)
  Process: 10746 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 10774 (code=exited, status=1/FAILURE)

Mar 17 13:48:20 server mysqld_safe[10774]: 170317 13:48:20 mysqld_safe Starting mysqld daemon                 with databases from /var/lib/mysql
Mar 17 13:48:20 server mysqld_safe[10774]: /usr/bin/mysqld_safe: line 139: /var/log/mariadb/ma                riadb.log: Permission denied
Mar 17 13:48:20 server mysqld_safe[10774]: /usr/bin/mysqld_safe: line 183: /var/log/mariadb/ma                riadb.log: Permission denied
Mar 17 13:48:20 server mysqld_safe[10774]: 170317 13:48:20 mysqld_safe mysqld from pid file /v                ar/run/mariadb/mariadb.pid ended
Mar 17 13:48:20 server mysqld_safe[10774]: /usr/bin/mysqld_safe: line 139: /var/log/mariadb/ma                riadb.log: Permission denied
Mar 17 13:48:20 server systemd[1]: mariadb.service: main process exited, code=exited, status=1                /FAILURE
Mar 17 13:48:21 server systemd[1]: mariadb.service: control process exited, code=exited status                =1
Mar 17 13:48:21 server systemd[1]: Failed to start MariaDB database server.
Mar 17 13:48:21 server systemd[1]: Unit mariadb.service entered failed state.
Mar 17 13:48:21 server systemd[1]: mariadb.service failed.
Cain Nuke
  • 77
  • 1
  • 1
  • 3
  • What happened when you ran the commands suggested by the error message? What do your logs say? – Jenny D Mar 17 '17 at 17:45
  • It says Unit mariadb.service entered failed state. – Cain Nuke Mar 17 '17 at 17:50
  • I just added the full error log now – Cain Nuke Mar 17 '17 at 17:53
  • You may get more, relevant information out of the other command it suggests but it looks like a permissions error. – user9517 Mar 17 '17 at 19:17
  • How can I solve it? – Cain Nuke Mar 17 '17 at 23:44
  • Heyyy! Stop voting down my thread and give me a solution instead! – Cain Nuke Mar 18 '17 at 03:48
  • 1
    I downvoted because you don't appear to have actually read the error messages. You should start by doing that. – Michael Hampton Mar 18 '17 at 06:09
  • I already did that, you idiot... – Cain Nuke Mar 18 '17 at 09:41
  • 1
    If you actually did read the error messages, you would have found the reason for the problem. `Mar 17 13:48:20 server mysqld_safe[10774]: /usr/bin/mysqld_safe: line 139: /var/log/mariadb/mariadb.log: Permission denied` is the problem. – Jenny D Mar 20 '17 at 15:14
  • 2
    Also, calling people idiots is a good way to not get help around here. – Jenny D Mar 20 '17 at 15:14
  • Regarding the failure due to `/usr/libexec/mariadb-prepare-db-dir`, that script looks broken to me. Also see CentOS [Issue 0014306, mariadb.service fails to start if /var/log/mysql owner is root:mysql](https://bugs.centos.org/view.php?id=14306). MariaDB has write access to the log file despite what the script reports. –  Dec 24 '17 at 02:35

1 Answers1

1

Find out the user your MariaDB is running as, and make sure that the logfile at /var/log/mariadb directory is owned by that user.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • Okay, seems like mariadb runs as mysql and the file was owned by root so I changed that and now the database starts but my script says it can communicate with it. – Cain Nuke Mar 18 '17 at 11:52
  • @Tero - How does one determine the MariaDB user? I have a similar problem (with even less information from systemd and the logs). The database's `/etc/my.conf` file does not change the default user, which should be `mysql:mysql`. –  Dec 24 '17 at 01:12
  • `ps aux | grep mysql` shows the user database is running as. – Tero Kilkanen Dec 24 '17 at 01:30
  • Thanks Tero. In our case the service failed to start. We had to use `systemctl show mariadb.service | grep -E 'User|Group'` to determine MariaDB's user and group. –  Dec 24 '17 at 02:33