1. 程式人生 > >關於運行mysql_install_db命令導致sudo systemctl start /restart mariadb.service啟動失敗問題

關於運行mysql_install_db命令導致sudo systemctl start /restart mariadb.service啟動失敗問題

mysql install db

運行環境:centos 7

數據庫:mariadb

問題描述:在yum安裝mariadb數據庫運行後運行了/var/lib/mysql_install_db命令,從而導致mariadb數據庫啟動或重啟都失敗。

故障解決:

[centos@centos mysql]$ sudo 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.

通過問題描述,首先想到的是運行sudo journalctl -xe 查看以下問題詳細信息,但是經查看並沒有比較詳細的error描述,使我想到了/var/log/mariadb/error.log,經查看獲取了以下錯誤信息,mysqld: File ‘./mysql-bin.000013‘ not found (Errcode: 13),根據提示,查看到底是不是mysql-bin.000013二進制日誌文件丟失,ls -l /var/lib/mysql/經查看此文件存在,但卻發現此文件的屬主與屬主和其他文件屬主與屬組權限不一樣,改其屬主和屬組 sudo chown mysql.mysql mysql-bin.000013,重新啟動mariadb問題得以解決。

總結:

在linux下大多數故障的發生都有日誌文件的記錄,遇到問題不要驚慌,首先查看問題描述,然後通過日誌文件描述來解決問題。不要盲目網上查答案。


[centos@centos mysql]$ sudo journalctl -xe
--
-- Unit mariadb.service has begun shutting down.
11月 04 18:22:46 centos systemd[1]: Stopped MariaDB database server.
-- Subject: Unit mariadb.service has finished shutting down
-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has finished shutting down.
11月 04 18:22:46 centos polkitd[636]: Unregistered Authentication Agent for unix-process:13180:865667 (system bus name :1.197,
11月 04 18:22:57 centos sudo[13209]: centos : TTY=pts/1 ; PWD=/var/lib/mysql ; USER=root ; COMMAND=/bin/systemctl start mari
11月 04 18:22:57 centos polkitd[636]: Registered Authentication Agent for unix-process:13210:866892 (system bus name :1.198 [/
11月 04 18:22:57 centos systemd[1]: Starting MariaDB database server...
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has begun starting up.
11月 04 18:22:57 centos mariadb-prepare-db-dir[13217]: Database MariaDB is probably initialized in /var/lib/mysql already, not
11月 04 18:22:57 centos mariadb-prepare-db-dir[13217]: If this is not the case, make sure the /var/lib/mysql is empty before r
11月 04 18:22:57 centos mysqld_safe[13252]: 171104 18:22:57 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log‘.
11月 04 18:22:57 centos mysqld_safe[13252]: 171104 18:22:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/my
11月 04 18:23:03 centos systemd[1]: mariadb.service: control process exited, code=exited status=1
11月 04 18:23:03 centos 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.
11月 04 18:23:03 centos systemd[1]: Unit mariadb.service entered failed state.
11月 04 18:23:03 centos systemd[1]: mariadb.service failed.
11月 04 18:23:03 centos polkitd[636]: Unregistered Authentication Agent for unix-process:13210:866892 (system bus name :1.198,
11月 04 18:23:16 centos sudo[13683]: centos : TTY=pts/1 ; PWD=/var/lib/mysql ; USER=root ; COMMAND=/bin/journalctl -xe


[centos@centos mysql]$ sudo tail -n 30 /var/log/mariadb/error.log

171104 18:22:59 Percona XtraDB (http://www.percona.com) 5.5.52-MariaDB-38.3 started; log sequence number 1597964
171104 18:22:59 [Note] Plugin ‘FEEDBACK‘ is disabled.
171104 18:22:59 [ERROR] mysqld: File ‘./mysql-bin.000013‘ not found (Errcode: 13)
171104 18:22:59 [ERROR] Failed to open log (file ‘./mysql-bin.000013‘, errno 13)
171104 18:22:59 [ERROR] Could not open log file
171104 18:22:59 [ERROR] Can‘t init tc log
171104 18:22:59 [ERROR] Aborting




本文出自 “落日羔羊” 博客,請務必保留此出處http://corallus.blog.51cto.com/7169241/1979013

關於運行mysql_install_db命令導致sudo systemctl start /restart mariadb.service啟動失敗問題