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

相關文章
相關標籤/搜索