CentOS 7中安装 MySQL 出现了 No package mysql-server available. Error: Nothing to do 错误

 CentOS 7 安装 mysql-server 爬坑

 发现问题

在centos 6安装 mysql-server是直接使用命令 yum -y install mysql-server ,但是在CentOS 7中出现了 No package mysql-server available. Error: Nothing to do 错误。详细错误信息如下:

[root@laona ~]# yum -y install mysql-server
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.cloud.aliyuncs.com
 * extras: mirrors.cloud.aliyuncs.com
 * updates: mirrors.cloud.aliyuncs.com
No package mysql-server available.
Error: Nothing to do

 解决方案

使用 MariaDB 代替 MySQL 命令即可

 产生原因

简单来说,MariaDB 是 MySQL 的fork,两者关系就好比 Red Hat 和 CentOS 的关系。从 MySQL 变成了 Oracle 甲骨文公司的产品后,MySQL 就已经从 RHEL 和 CentOS 所提供的套件清单移除了。

 安装 MySQL

 1. 安裝 mariadb 与 mariadb-server 套件
sudo yum -y install mariadb mariasb-client
 2. 启动 MySQL 服务
sudo systemctl start mariadb
 3. 启动 MariaDB 服务,让 MariaDB 服务每次开机会自启
sudo systemctl enable mariadb
 4. 检查启动状态
sudo systemctl status mariadb
 5. 加强 MariaDB 安装的安全性
sudo mysql_secure_installation

这个shell主要是有以下作用:- 设定 root 账号的密码- 禁止 root 丛非本人登录- 移除 anonymous 匿名用户登录- 移除测试数据库

 6. 查询版本号
mysql -v

 登录测试

键入以下指令,输入密码即可。

mysql -u root -h localhost -p

----

人若无名,专心练剑!

喜欢的朋友可以留下你的赞!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值