CentOS7启动MySQL报错,解决Failed to start mysqld.service: Unit not found
当输入命令
[root@localhost ~]# systemctl start mysql.service
要启动MySQL数据库是却是这样的提示
Failed to start mariadb-service.service: Unit not found
解决方法如下:
首先需要安装mariadb-server
[root@localhost ~]# yum install -y mariadb-server
启动服务
[root@localhost ~]# systemctl start mariadb.service
添加到开机启动
[root@localhost ~]# systemctl enable mariadb.service
[root@localhost ~]# systemctl start mariadb-service
Failed to start mariadb-service.service: Unit not found.
[root@localhost ~]# systemctl start mariadb-service
Failed to start mariadb-service.service: Unit not found.
[root@localhost ~]# yum install mariadb-server
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* elrepo: ftp.ne.jp
* extras: mirrors.163.com
* updates: mirrors.163.com
软件包 1:mariadb-server-5.5.65-1.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# systemctl start mariadb-service
Failed to start mariadb-service.service: Unit not found.
[root@localhost ~]# yum install -y mariadb mariadb-server
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* elrepo: ftp.ne.jp
* extras: mirrors.163.com
* updates: mirrors.163.com
软件包 1:mariadb-5.5.65-1.el7.x86_64 已安装并且是最新版本
软件包 1:mariadb-server-5.5.65-1.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# systemctl status mariadb-service
Unit mariadb-service.service could not be found.
[root@localhost ~]# ps -ef | grep mariadb
root 63544 60579 0 20:42 pts/0 00:00:00 grep --color=auto mariadb
[root@localhost ~]# yum remove mariadb-libs.x86_64
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.65-1.el7 将被 删除
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 perl-DBD-MySQL-4.023-6.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-9.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 perl-DBD-MySQL-4.023-6.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-9.el7.x86_64 需要
--> 正在处理依赖关系 mariadb-libs(x86-64) = 1:5.5.65-1.el7,它被软件包 1:mariadb-server-5.5.65-1.el7.x86_64 需要
--> 正在处理依赖关系 mariadb-libs(x86-64) = 1:5.5.65-1.el7,它被软件包 1:mariadb-5.5.65-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.65-1.el7 将被 删除
---> 软件包 mariadb-server.x86_64.1.5.5.65-1.el7 将被 删除
---> 软件包 perl-DBD-MySQL.x86_64.0.4.023-6.el7 将被 删除
---> 软件包 postfix.x86_64.2.2.10.1-9.el7 将被 删除
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在删除:
mariadb-libs x86_64 1:5.5.65-1.el7 @anaconda 4.4 M
为依赖而移除:
mariadb x86_64 1:5.5.65-1.el7 @base 49 M
mariadb-server x86_64 1:5.5.65-1.el7 @base 58 M
perl-DBD-MySQL x86_64 4.023-6.el7 @base 323 k
postfix x86_64 2:2.10.1-9.el7 @anaconda 12 M
事务概要
================================================================================
移除 1 软件包 (+4 依赖软件包)
安装大小:124 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : 1:mariadb-server-5.5.65-1.el7.x86_64 1/5
正在删除 : 1:mariadb-5.5.65-1.el7.x86_64 2/5
正在删除 : perl-DBD-MySQL-4.023-6.el7.x86_64 3/5
正在删除 : 2:postfix-2.10.1-9.el7.x86_64 4/5
正在删除 : 1:mariadb-libs-5.5.65-1.el7.x86_64 5/5
验证中 : 1:mariadb-server-5.5.65-1.el7.x86_64 1/5
验证中 : 1:mariadb-libs-5.5.65-1.el7.x86_64 2/5
验证中 : perl-DBD-MySQL-4.023-6.el7.x86_64 3/5
验证中 : 1:mariadb-5.5.65-1.el7.x86_64 4/5
验证中 : 2:postfix-2.10.1-9.el7.x86_64 5/5
删除:
mariadb-libs.x86_64 1:5.5.65-1.el7
作为依赖被删除:
mariadb.x86_64 1:5.5.65-1.el7 mariadb-server.x86_64 1:5.5.65-1.el7
perl-DBD-MySQL.x86_64 0:4.023-6.el7 postfix.x86_64 2:2.10.1-9.el7
完毕!
[root@localhost ~]# yum remove mariadb
已加载插件:fastestmirror
参数 mariadb 没有匹配
不删除任何软件包
[root@localhost ~]# yum install -y mariadb-server
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* elrepo: ftp.ne.jp
* extras: mirrors.163.com
* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb-server.x86_64.1.5.5.65-1.el7 将被 安装
--> 正在处理依赖关系 mariadb-libs(x86-64) = 1:5.5.65-1.el7,它被软件包 1:mariadb-server-5.5.65-1.el7.x86_64 需要
--> 正在处理依赖关系 mariadb(x86-64) = 1:5.5.65-1.el7,它被软件包 1:mariadb-server-5.5.65-1.el7.x86_64 需要
--> 正在处理依赖关系 perl-DBD-MySQL,它被软件包 1:mariadb-server-5.5.65-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.65-1.el7 将被 安装
---> 软件包 mariadb-libs.x86_64.1.5.5.65-1.el7 将被 安装
---> 软件包 perl-DBD-MySQL.x86_64.0.4.023-6.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
mariadb-server x86_64 1:5.5.65-1.el7 base 11 M
为依赖而安装:
mariadb x86_64 1:5.5.65-1.el7 base 8.7 M
mariadb-libs x86_64 1:5.5.65-1.el7 base 759 k
perl-DBD-MySQL x86_64 4.023-6.el7 base 140 k
事务概要
================================================================================
安装 1 软件包 (+3 依赖软件包)
总下载量:21 M
安装大小:112 M
Downloading packages:
(1/4): mariadb-libs-5.5.65-1.el7.x86_64.rpm | 759 kB 00:00
(2/4): perl-DBD-MySQL-4.023-6.el7.x86_64.rpm | 140 kB 00:00
(3/4): mariadb-5.5.65-1.el7.x86_64.rpm | 8.7 MB 00:01
(4/4): mariadb-server-5.5.65-1.el7.x86_64.rpm | 11 MB 00:02
--------------------------------------------------------------------------------
总计 9.4 MB/s | 21 MB 00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : 1:mariadb-libs-5.5.65-1.el7.x86_64 1/4
正在安装 : perl-DBD-MySQL-4.023-6.el7.x86_64 2/4
正在安装 : 1:mariadb-5.5.65-1.el7.x86_64 3/4
正在安装 : 1:mariadb-server-5.5.65-1.el7.x86_64 4/4
验证中 : 1:mariadb-server-5.5.65-1.el7.x86_64 1/4
验证中 : 1:mariadb-libs-5.5.65-1.el7.x86_64 2/4
验证中 : perl-DBD-MySQL-4.023-6.el7.x86_64 3/4
验证中 : 1:mariadb-5.5.65-1.el7.x86_64 4/4
已安装:
mariadb-server.x86_64 1:5.5.65-1.el7
作为依赖被安装:
mariadb.x86_64 1:5.5.65-1.el7 mariadb-libs.x86_64 1:5.5.65-1.el7
perl-DBD-MySQL.x86_64 0:4.023-6.el7
完毕!
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since 六 2020-07-11 20:44:47 CST; 8s ago
Process: 64645 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 64533 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 64644 (mysqld_safe)
Tasks: 20
Memory: 106.1M
CGroup: /system.slice/mariadb.service
├─64644 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─64807 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysq...
7月 11 20:44:44 localhost.localdomain systemd[1]: Starting MariaDB database ...
7月 11 20:44:44 localhost.localdomain mariadb-prepare-db-dir[64533]: Initial...
7月 11 20:44:45 localhost.localdomain mariadb-prepare-db-dir[64533]: 200711 ...
7月 11 20:44:45 localhost.localdomain mariadb-prepare-db-dir[64533]: 200711 ...
7月 11 20:44:45 localhost.localdomain mariadb-prepare-db-dir[64533]: PLEASE ...
7月 11 20:44:45 localhost.localdomain mysqld_safe[64644]: 200711 20:44:45 my...
7月 11 20:44:45 localhost.localdomain mysqld_safe[64644]: 200711 20:44:45 my...
7月 11 20:44:47 localhost.localdomain systemd[1]: Started MariaDB database s...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2020-07-11 20:44:47 CST; 54s ago
Main PID: 64644 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─64644 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─64807 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysq...
7月 11 20:44:44 localhost.localdomain systemd[1]: Starting MariaDB database ...
7月 11 20:44:44 localhost.localdomain mariadb-prepare-db-dir[64533]: Initial...
7月 11 20:44:45 localhost.localdomain mariadb-prepare-db-dir[64533]: 200711 ...
7月 11 20:44:45 localhost.localdomain mariadb-prepare-db-dir[64533]: 200711 ...
7月 11 20:44:45 localhost.localdomain mariadb-prepare-db-dir[64533]: PLEASE ...
7月 11 20:44:45 localhost.localdomain mysqld_safe[64644]: 200711 20:44:45 my...
7月 11 20:44:45 localhost.localdomain mysqld_safe[64644]: 200711 20:44:45 my...
7月 11 20:44:47 localhost.localdomain systemd[1]: Started MariaDB database s...
Hint: Some lines were ellipsized, use -l to show in full.