Centos 7 安裝Mysql-5.7
阿新 • • 發佈:2018-12-12
==========運維之路
- 環境如下
[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[[email protected] ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[[email protected] ~]# getenforce
Disabled
- 新增 Yum 源
[[email protected] ~]# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
- 檢查 Yum 源 預設版本為 Mysql 8.0
[[email protected] ~]# yum repolist all | grep mysql mysql80-community/x86_64 MySQL 8.0 Community Server enabled: 33 mysql80-community-source MySQL 8.0 Community Server - disabled
- 選擇 Mysql 版本 預設版本為 Mysql 8.0 ,這裡改為 Mysql 5.7
[[email protected] ~]# yum-config-manager --disable mysql80-community
[[email protected] ~]# yum-config-manager --enable mysql57-community
# 或者
[[email protected] ~]# vi /etc/yum.repos.d/mysql-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1 #enabled等於1即為選擇該版本
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/
enabled=0 #將預設8.0版本關閉
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
- 下載 Mysql
[[email protected] ~]# yum install -y mysql-community-server
- 啟動 Mysql
[[email protected] ~]# systemctl start mysqld
- 獲取密碼
[[email protected] ~]# grep 'temporary password' /var/log/mysqld.log
2018-09-07T09:18:38.526311Z 1 [Note] A temporary password is generated for [email protected]: m;:)n3;*:1wE
- 連線 Mysql
[[email protected] ~]# mysql -uroot -p
Enter password: #輸入上一步獲取到的密碼 m;:)n3;*:1wE
- 更改密碼
# 新密碼不少於8位,至少有1個大小寫字母,1個數字,1個特殊字元
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
Query OK, 0 rows affected (0.00 sec)
- 來自官方文件
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html