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 错误。详细错误信息以下:mysql

[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 套件sql

sudo yum -y install mariadb mariasb-client

#### 2. 启动 MySQL 服务shell

sudo systemctl start mariadb

#### 3. 启动 MariaDB 服务,让 MariaDB 服务每次开机会自启数据库

sudo systemctl enable mariadb

#### 4. 检查启动状态centos

sudo systemctl status mariadb

#### 5. 增强 MariaDB 安装的安全性安全

sudo mysql_secure_installation

这个shell主要是有如下做用: - 设定 root 帐号的密码 - 禁止 root 丛非本人登陆 - 移除 anonymous 匿名用户登陆 - 移除测试数据库 #### 6. 查询版本号测试

mysql -v

### 登陆测试 键入如下指令,输入密码便可。code

mysql -u root -h localhost -p

人若无名,专心练剑! 喜欢的朋友能够留下你的赞!server

相关文章
相关标签/搜索