在CentOS7中,无法启动MySQL

时间:2015-06-26 07:13:43

标签: mysql centos

我想在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。我该如何解决这个问题?

5 个答案:

答案 0 :(得分:12)

当你跑

yum install mysql

命令默认情况下会安装mariadb而非mysql。所以请尝试以下命令

yum list installed | grep mariadb

如果缺少mariadb-server,请尝试以下命令

yum install mariadb-server

安装服务器包然后启动服务

systemctl start mariadb

service mariadb start

我的问题以这种方式解决了。 感谢

答案 1 :(得分:11)

要检查所需的包,请键入给定的命令:

$ 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)

答案 2 :(得分:3)

检查/etc/init.d/以获取您的mysql服务名称,然后

service mysql_service_name start

在centos上它是: 服务mysqld start 或者对于MariaDB: 服务mariadb开始

答案 3 :(得分:1)

mysql-community-common似乎与基于Red Hat的* nix v7安装一起安装,反过来又与mariadb安装冲突。我正在使用Oracle Linux 7,只是遇到了这个问题。在全新安装OL7之后,安装了mysql-community-common和mysql-community-libs。删除mysql-community-common THEN install 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:~>

答案 4 :(得分:0)

CentOS7用mariaDB代替Mysql,可以像使用Mysql一样使用mariaDB。或者,您可以从mysql.com下载回购。然后您可以安装mysql