在CentOS7,无法启动MySQL
Posted
技术标签:
【中文标题】在CentOS7,无法启动MySQL【英文标题】:In CentOS7, can not start MySQL 【发布时间】:2015-09-13 01:13:16 【问题描述】:我想在 CentOS7 上使用 mysql。 使用 yum 安装 MySQL 包。
[root@node01 ~]# yum install mysql mysql-*
那么,
[root@node01 ~]# systemctl start mysqld.service
Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
我无法执行 MySQL。我该如何解决这个问题?
【问题讨论】:
我认为你必须使用 MariaDB 而不是 MySql。 【参考方案1】:当你跑步时
yum install mysql
命令默认安装mariadb
而不是mysql
。所以试试下面这个命令
yum list installed | grep mariadb
如果 mariadb-server 丢失,请尝试以下命令
yum install mariadb-server
它安装服务器包然后启动服务
systemctl start mariadb
或
service mariadb start
我的问题就这样解决了。 谢谢
【讨论】:
如果从早期版本的 MariaDB 到 MariaDB 10.4.x,这个答案可以救命。【参考方案2】:要检查所需的包,请输入给定的命令:
$ rpm -qa | grep mariadb
输出:
mariadb-libs-5.5.44-2.el7.centos.x86_64
mariadb-5.5.44-2.el7.centos.x86_64
mariadb-devel-5.5.44-2.el7.centos.x86_64
mariadb-server-5.5.44-2.el7.centos.x86_64
如果最后一个包不存在,输入给定的命令:
$ sudo yum -y install mariadb-server
$ sudo systemctl start mariadb
$ cat /etc/redhat-release
输出:
CentOS Linux release 7.2.1511 (Core)
【讨论】:
我也有相同的配置,但是上面提到的方法都不起作用。从上面的命令Package 1:mariadb-server-5.5.50-1.el7_2.x86_64 is obsoleted by mysql-community-server-5.7.16-1.el7.x86_64 which is already installed Nothing to do
安装 mariadb-server 时出现此错误。我该怎么办??
我可以补充一点,在我的情况下,mariadb-devel-5.5.44-2.el7.centos.x86_64 不存在,所以我 $ yum install -y mariadb-dev 它能够开始。
按照您的指示,mariadb.service 已从我的集群中删除。【参考方案3】:
检查 /etc/init.d/ 以获取您的 mysql 服务名称,然后
服务 mysql_service_name 启动
在 centos 上,它是: 服务 mysqld 启动 或者对于 MariaDB: 服务 mariadb 启动
【讨论】:
该功能在超级管理员登录后生效。谢谢!【参考方案4】:mysql-community-common 似乎与基于 Red Hat 的 *nix v7 安装一起安装,而它又与 mariadb 安装冲突。我正在使用 Oracle Linux 7,只是遇到了这个问题。全新安装 OL7 后,将安装 mysql-community-common 和 mysql-community-libs。删除 mysql-community-common 然后安装 mariadb,一切都像冠军一样工作。
root@ol7-101:~> yum list installed | grep mysql
mysql-community-common.x86_64 5.6.27-2.el7 @Server-Mysql/7.2
mysql-community-libs.x86_64 5.6.27-2.el7 @Server-Mysql/7.2
root@ol7-101:~>
root@ol7-101:~> yum install mariadb-server mariadb -y
Loaded plugins: ulninfo
Resolving Dependencies
--> Running transaction check
[...]
86_64 conflicts with file from package mysql-community-common-5.6.27-2.el7.x86_64
file /usr/share/mysql/spanish/errmsg.sys from install of MariaDB-server-10.1.11-1.el7.centos.x86_64 conflicts with file from package mysql-community-common-5.6.27-2.el7.x86_64
file /usr/share/mysql/swedish/errmsg.sys from install of MariaDB-server-10.1.11-1.el7.centos.x86_64 conflicts with file from package mysql-community-common-5.6.27-2.el7.x86_64
file /usr/share/mysql/ukrainian/errmsg.sys from install of MariaDB-server-10.1.11-1.el7.centos.x86_64 conflicts with file from package mysql-community-common-5.6.27-2.el7.x86_64
file /usr/share/mysql/errmsg-utf8.txt from install of MariaDB-server-10.1.11-1.el7.centos.x86_64 conflicts with file from package mysql-community-common-5.6.27-2.el7.x86_64
Error Summary
-------------
root@ol7-101:~> systemctl start mariadb
Failed to start mariadb.service: Unit mariadb.service failed to load: No such file or directory.
root@ol7-101:~> systemctl enable mariadb.service
Failed to execute operation: Access denied
root@ol7-101:~>
root@ol7-101:~> yum erase mysql-community-common.x86_64
Loaded plugins: ulninfo
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-common.x86_64 0:5.6.27-2.el7 will be erased
--> Finished Dependency Resolution
[...]
root@ol7-101:~> yum install mariadb mariadb-libs mariadb-server -y
Loaded plugins: ulninfo
Resolving Dependencies
--> Running transaction check
[...]
Complete!
root@ol7-101:~> systemctl start mariadb.service
root@ol7-101:~>
root@ol7-101:~> systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
root@ol7-101:~>
【讨论】:
【参考方案5】:CentOS7 用mariaDB 代替Mysql,可以和Mysql 一样使用mariaDB。或者你可以从mysql.com 下载repo。然后就可以安装mysql了
【讨论】:
以上是关于在CentOS7,无法启动MySQL的主要内容,如果未能解决你的问题,请参考以下文章