关于运行mysql_install_db命令导致sudosystemctlstart/restartmariadb.service启动失败问题
运行环境: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
本文题目:关于运行mysql_install_db命令导致sudosystemctlstart/restartmariadb.service启动失败问题
本文来源:http://cdiso.cn/article/poepid.html