关于运行mysql_install_db命令导致sudo systemctl start /restart mariadb.service启动失败问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于运行mysql_install_db命令导致sudo systemctl start /restart mariadb.service启动失败问题相关的知识,希望对你有一定的参考价值。

运行环境:centos 7

数据库:mariadb

问题描述:在yum安装mariadb数据库运行后运行了/var/lib/mysql_install_db命令,从而导致mariadb数据库启动或重启都失败。

故障解决:

[[email protected] 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下大多数故障的发生都有日志文件的记录,遇到问题不要惊慌,首先查看问题描述,然后通过日志文件描述来解决问题。不要盲目网上查答案。


[[email protected] 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


[[email protected] 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启动失败问题的主要内容,如果未能解决你的问题,请参考以下文章

linux安装mysql时执行 scripts/mysql_install_db --user=mysql报错 bash: mysql_install_db:未找到命令

linux mysql ,用scripts/mysql_install_db显示没有文件,scripts/mysql_install_db.sh权限不足,我是root

bash:scripts/mysql_install_db: 没有这样的文件或目录

6-10

初始化mysql数据库 /usr/bin/mysql_install_db执行时报错

在linux中启动mysql服务的命令