Centos7安装 mariadb启动错误解决

Centos7安装 mariadb启动错误解决,第1张

本人遇到mariadb 启动错误故障解决过程分享。

故障现象 :

Centos7 使用 yum -y install mariadb mariadb-server  安装完成mariadb后启动错误。

错误信息:

[root@iZ882mt6umfZ ~]# systemctl status mariadb.service

[0m mariadb.service - MariaDB database server

Loaded: loaded (/usr/lib/systemd/system/mariadb.servicedisabledvendor preset: disabled)

Active: failed (Result: exit-code) since Fri 2019-03-01 09:25:54 CST9s ago

Process: 309 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)

Process: 308 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)

Process: 32745 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)

Main PID: 308 (code=exited, status=0/SUCCESS)

Mar 01 09:25:53 iZ882mt6umfZ systemd[1]: Starting MariaDB database server...

Mar 01 09:25:53 iZ882mt6umfZ mariadb-prepare-db-dir[32745]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.

Mar 01 09:25:53 iZ882mt6umfZ mariadb-prepare-db-dir[32745]: If this is not the case, make sure the /var/lib/mysql is empty before running mariad...db-dir.

Mar 01 09:25:53 iZ882mt6umfZ mysqld_safe[308]: 190301 09:25:53 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.

Mar 01 09:25:53 iZ882mt6umfZ mysqld_safe[308]: 190301 09:25:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Mar 01 09:25:54 iZ882mt6umfZ systemd[1]: mariadb.service: control process exited, code=exited status=1

Mar 01 09:25:54 iZ882mt6umfZ systemd[1]: Failed to start MariaDB database server.

Mar 01 09:25:54 iZ882mt6umfZ systemd[1]: Unit mariadb.service entered failed state.

Mar 01 09:25:54 iZ882mt6umfZ systemd[1]: mariadb.service failed.

解决方案:

yum install mariadb*

chown -R mysql:mysql /var/lib/mysql/

启动正常:

root@iZ882mt6umfZ ~]# systemctl start mariadb

[root@iZ882mt6umfZ ~]# systemctl status mariadb

[0m mariadb.service - MariaDB database server

Loaded: loaded (/usr/lib/systemd/system/mariadb.servicedisabledvendor preset: disabled)

Active: active (running) since Fri 2019-03-01 09:38:58 CST13s ago

Process: 1875 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)

Process: 1843 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)

Main PID: 1874 (mysqld_safe)

mariadb配置文件执行顺序是

1、创建/data目录mkdir/data,chmod777/data(要给这个目录至少要附加读写权限)。

2、把mariadb服务停掉:systemctlstopmariadb.service。

3、把/var/lib/mysql整个目录复制到/data,cp-r/var/lib/mysql//data/这样就把MySQL的数据文档复制到了/data下。

4、编辑mariadb的配置文档/etc/my.cnf。

5、chown-Rmysql:mysql/data/mysql。

6、重新启动mariadb服务systemctlstartmariadb.service。


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/18493.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-02-14
下一篇2023-02-14

发表评论

登录后才能评论

评论列表(0条)

    保存