centos7 安装mysql 解决 Failed to start mariadb.service: Unit not found.

涉及好多个错误。一环套一环的。
首先安装问题

首先需要安装mariadb-server
systemctl start mariadb.service

会报错:Failed to start mariadb.service: Unit not found.

yum install mariadb

然后使用命令systemctl start mariadb,提示如下:

Failed to start mariadb.service: Unit mariadb.service failed to load: No such file or directory

意思找不到mariadb这个服务。之所以找不到,是因为mariadb的安装本身就没有完成,执行以下命令,查看mariadb的依赖情况:

执行以下,安装缺少的依赖包:

$ yum install mariadb-embedded mariadb-libs mariadb-bench mariadb mariadb-sever

然后再启动mariadb,正常,如果要设置开机自启动mariadb,使用以下命令:

$ systemctl enable mariadb

但是还是报错了:

Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.

意思是执行

systemctl status mariadb.service

查看报错信息,从这里能够解决问题所在

4月 04 15:41:57 zhujiwu systemd[1]: Starting MariaDB database server...
4月 04 15:41:57 zhujiwu mariadb-prepare-db-dir[19135]: Database MariaDB is probably initialized in /www/server/data already, no... done.
4月 04 15:41:57 zhujiwu mariadb-prepare-db-dir[19135]: If this is not the case, make sure the /www/server/data is empty before ...b-dir.
4月 04 15:41:58 zhujiwu mysqld_safe[19166]: 190404 15:41:58 mysqld_safe Logging to '/www/server/data/zhujiwu.err'.
4月 04 15:41:58 zhujiwu mysqld_safe[19166]: 190404 15:41:58 mysqld_safe A mysqld process already exists
4月 04 15:41:58 zhujiwu systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
4月 04 15:41:58 zhujiwu systemd[1]: mariadb.service: control process exited, code=exited status=1
4月 04 15:41:58 zhujiwu systemd[1]: Failed to start MariaDB database server.
4月 04 15:41:58 zhujiwu systemd[1]: Unit mariadb.service entered failed state.
4月 04 15:41:58 zhujiwu systemd[1]: mariadb.service failed.

重要的是这一条信息
4月 04 15:41:58 zhujiwu mysqld_safe[19166]: 190404 15:41:58 mysqld_safe A mysqld process already exists
解决方案:
centos7 安装mysql 解决 Failed to start mariadb.service: Unit not found._第1张图片
然后执行

restart mariadb.service
status mariadb.service

成功运行

mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since 四 2019-04-04 15:50:46 CST; 3s ago
  Process: 19929 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 19895 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 19926 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─19926 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─20494 /usr/libexec/mysqld --basedir=/usr --datadir=/www/server/data --plugin-dir=/usr/lib64/mysql/plugin --log-error=/www...

4月 04 15:50:44 zhujiwu systemd[1]: Starting MariaDB database server...
4月 04 15:50:44 zhujiwu mariadb-prepare-db-dir[19895]: Database MariaDB is probably initialized in /www/server/data already, no... done.
4月 04 15:50:44 zhujiwu mariadb-prepare-db-dir[19895]: If this is not the case, make sure the /www/server/data is empty before ...b-dir.
4月 04 15:50:44 zhujiwu mysqld_safe[19926]: 190404 15:50:44 mysqld_safe Logging to '/www/server/data/zhujiwu.err'.
4月 04 15:50:45 zhujiwu mysqld_safe[19926]: 190404 15:50:45 mysqld_safe Starting mysqld daemon with databases from /www/server/data
4月 04 15:50:46 zhujiwu systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.

你可能感兴趣的:(MySql,bug)