3

failed to start mysql in Fedora 17. I am using root account to run the below commands and selinux is disabled.

service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
Job for mariadb.service failed. See 'systemctl status mariadb.service' and 'journalctl -xn' for details.

systemctl status mariadb.service
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled)
   Active: failed (Result: exit-code) since Tue 2014-09-23 11:29:32 SGT; 10s ago
  Process: 4251 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 4250 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=1/FAILURE)
  Process: 4222 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 4250 (code=exited, status=1/FAILURE)

Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: 140923 11:29:32 mysqld_safe WSREP: Running position recovery with --log_error='/var/...er.pid'
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: /usr/bin/mysqld_safe: line 138: /var/log/mariadb/mariadb.log: Permission denied
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: /usr/bin/mysqld_safe: line 182: /var/log/mariadb/mariadb.log: Permission denied
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: 140923 11:29:32 mysqld_safe WSREP: Failed to recover position:
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: ''
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: /usr/bin/mysqld_safe: line 138: /var/log/mariadb/mariadb.log: Permission denied
Sep 23 11:29:32 acer-4930g systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Sep 23 11:29:32 acer-4930g systemd[1]: mariadb.service: control process exited, code=exited status=1
Sep 23 11:29:32 acer-4930g systemd[1]: Failed to start MariaDB database server.
Sep 23 11:29:32 acer-4930g systemd[1]: Unit mariadb.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.

journalctl -xn
-- Logs begin at Sat 2014-04-26 15:18:22 SGT, end at Tue 2014-09-23 11:29:34 SGT. --
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: /usr/bin/mysqld_safe: line 138: /var/log/mariadb/mariadb.log: Permission denied
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: /usr/bin/mysqld_safe: line 182: /var/log/mariadb/mariadb.log: Permission denied
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: 140923 11:29:32 mysqld_safe WSREP: Failed to recover position:
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: ''
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: /usr/bin/mysqld_safe: line 138: /var/log/mariadb/mariadb.log: Permission denied
Sep 23 11:29:32 acer-4930g systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Sep 23 11:29:32 acer-4930g systemd[1]: mariadb.service: control process exited, code=exited status=1
Sep 23 11:29:32 acer-4930g systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mariadb.service has failed.
-- 
-- The result is failed.
Sep 23 11:29:32 acer-4930g systemd[1]: Unit mariadb.service entered failed state.
Sep 23 11:29:34 acer-4930g PackageKit[4204]: daemon quit

getenforce 
Permissive

Then I changed ownership of the mariadb log file from root to mysql but still failed:

[root@acer-4930g ~]# ls -ld /var/log/mariadb/
drwxr-x---. 2 mysql mysql 4096 Sep 23 11:02 /var/log/mariadb/
[root@acer-4930g ~]# ls -l /var/log/mariadb/mariadb.log 
-rw-rw----. 1 root root 554 Sep 23 11:02 /var/log/mariadb/mariadb.log
[root@acer-4930g ~]# chown -R mysql:mysql /var/log/mariadb -chR
[root@acer-4930g ~]# systemctl restart mariadb.service 
Job for mariadb.service failed. See 'systemctl status mariadb.service' and 'journalctl -xn' for details.

[root@acer-4930g ~]# systemctl status mariadb.service 
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled)
   Active: failed (Result: exit-code) since Tue 2014-09-23 14:58:09 SGT; 3min 4s ago
  Process: 6890 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 6889 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=1/FAILURE)
  Process: 6861 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 6889 (code=exited, status=1/FAILURE)

Sep 23 14:58:09 acer-4930g mysqld_safe[6889]: 140923 14:58:08 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade ...ate it.
Sep 23 14:58:09 acer-4930g mysqld_safe[6889]: 140923 14:58:08 [ERROR] Aria engine is not enabled or did not start. The Aria engine...-tables
Sep 23 14:58:09 acer-4930g mysqld_safe[6889]: 140923 14:58:08 [ERROR] Aborting
Sep 23 14:58:09 acer-4930g mysqld_safe[6889]: 140923 14:58:08  InnoDB: Starting shutdown...
Sep 23 14:58:09 acer-4930g mysqld_safe[6889]: 140923 14:58:09  InnoDB: Shutdown completed; log sequence number 1597945
Sep 23 14:58:09 acer-4930g mysqld_safe[6889]: 140923 14:58:09 [Note] /usr/libexec/mysqld: Shutdown complete'
Sep 23 14:58:09 acer-4930g systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Sep 23 14:58:09 acer-4930g systemd[1]: mariadb.service: control process exited, code=exited status=1
Sep 23 14:58:09 acer-4930g systemd[1]: Failed to start MariaDB database server.
Sep 23 14:58:09 acer-4930g systemd[1]: Unit mariadb.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
2

Permissions?

You're showing the command service mysqld start but are you prefixing that with a sudo? I suspect you do not have permissions to start this service based on the fact that you're getting these "permission denied messages" in the output you've included in your Q.

Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: /usr/bin/mysqld_safe: line 138: /var/log/mariadb/mariadb.log: Permission denied
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: /usr/bin/mysqld_safe: line 182: /var/log/mariadb/mariadb.log: Permission denied
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: 140923 11:29:32 mysqld_safe WSREP: Failed to recover position:
Sep 23 11:29:32 acer-4930g mysqld_safe[4250]: ''

If you are in fact using sudo then I'd move my attention to the directory & files mentioned in the logs messages above. Focus on this directory/file:

$ ls -ld /var/log/mariadb
$ ls -l /var/log/mariadb/mariadb.log

I found these commands in this AskFedora Q&A titled: mariadb service don't start: permission denied, which should fix your issue:

$ sudo chown mysql:mysql /var/log/mariadb -chR

followed by:

$ sudo systemctl restart mariadb.service && \
    sudo systemctl status mariadb.service

It appears that the MariaDB log files do not allow the user, mysql access to them, the above commands will fix this problem.

DB corrupt?

If you still continue to have problems and are confronted with errors such as:

Sep 23 14:58:09 acer-4930g mysqld_safe[6889]: 140923 14:58:08 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade ...ate it.

You can also confirm now that the permissions problem above has been resolved, in the MariaDB log file for messages like so:

Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
FATAL ERROR: Upgrade failed

Either message is basically telling you that there were issues in upgrading your MySQL DB to a Maria DB one. If it's a DB with nothing you care about in it, you can simply move it or remove it. This will require that you first remove the MariaDB package, and then re-install it.

Example

$ sudo yum remove mariadb-server

### To remove
$ sudo rm -rf /usr/lib/mysql

### To move
$ sudo mv /usr/lib/mysql /usr/lib/mysql.orig

$ sudo yum install mariadb-server

NOTE: Source for the above tip: Trouble starting mariadb service.

One thing with the above tip that I cannot confirm, is whether the directory to move/remove is /usr/lib/mysql. or /var/lib/mysql. I'm not sure if that' a typo in that tip or not. So I would do the above with /usr/lib/mysql first and if it doesn't work then repeat the steps but with /var/lib/mysql. I would use the remove method first, if things work OK, then come back and remove the corrupted directory.

NOTE: /var/lib/mysql is where the DB files live, the /usr/lib/mysql directory is where the various plugins live.

  • changed ownership of log directory and file but still cannot start – Xianlin Sep 23 '14 at 7:02
  • @Xianlin - same issue as yourself: bbs.archlinux.org/viewtopic.php?id=160277. I'd hold off in doing what's suggested here unless you're feeling desperate, these options seem a little aggressive in deleting the DB files and such. – slm Sep 23 '14 at 10:53
  • @Xianlin - also is there more to what you're doing here then you mentioned? Was there an upgrade done from MySQL to MariaDB here and there was a pre-existing DB on the system? – slm Sep 23 '14 at 11:05
  • @Xianlin - see updates. – slm Sep 23 '14 at 12:00
  • 1
    my problem was solved by chown /var/lib/mysql to mysql:mysql thanks! – jim smith Mar 28 '15 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.