Yum安裝 mysql

標簽(空格分隔): mysql


1 安裝源

參考 https://dev.mysql.com/downloads/repo/yum/

# CentOS 6 / RHEL 6
[root@localhost ~]# yum install https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm

# CentOS 7 / RHEL 7
[root@localhost ~]# yum install https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

2 指定安裝版本

查看所有可用版本

[root@localhost ~]#  yum repolist all | grep mysql

使用 mysql5.6

# 關閉當前啟用版本
[root@localhost ~]#  yum-config-manager --disable mysql57-community

# 啟用 mysql5.6
[root@localhost ~]#  yum-config-manager --enable  mysql56-community

# 檢查當前版本
[root@localhost ~]#  yum repolist enabled | grep mysql

3 安裝和升級

#  安裝
[root@localhost ~]# yum install mysql-community-server

安裝的軟件有 mysql-community-server,mysql-community-client,mysql-community-common,mysql-community-libs

4 啟動 Mysql-Server

啟動

# CentOS 6 / RHEL 6
[root@localhost ~]# service mysqld start

# CentOS 7 / RHEL 7
[root@localhost ~]# systemctl start mysqld.service

查看運行狀態(tài)

# CentOS 6 / RHEL 6
[root@localhost ~]# service mysqld status

# CentOS 7 / RHEL 7
[root@localhost ~]# systemctl status mysqld.service

在第一次啟動時,MySQL Server 將會初始化:

  1. 服務器初始化
  2. 在數據目錄創(chuàng)建 SSL certificate 和 key 文件
  3. 安裝并啟動 validate_password plugin
  4. 創(chuàng)建超級用戶 'root'@'localhost',密碼寫入錯誤日志文件

獲得臨時密碼:

[root@localhost ~]#  grep 'temporary password' /var/log/mysqld.log

使用臨時密碼登陸后,請立即修改密碼

[root@localhost ~]#  mysql -uroot -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

Note

MySQL's validate_password plugin is installed by default. This will
require that passwords contain at least one upper case letter, one
lower case letter, one digit, and one special character, and that the
total password length is at least 8 characters.

5 運行安全程序( MySQL 5.6 )

mysql_secure_installation 執(zhí)行一些安全化操作,例如設置 root 用戶密碼,移除匿名用戶等。務必在MySQL 5.6安裝完成后執(zhí)行

[root@localhost ~]# mysql_secure_installation

MySQL 5.7 不需要執(zhí)行這個程序,因為 yum 安裝過程中已經完成了這個操作

6 升級

[root@localhost ~]# yum  update mysql-community-server

7 相關目錄

參考

A Quick Guide to Using the MySQL Yum Repository

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容