Centos7安裝MySQL5.7版本
系統環境:Centos7
mysql版本:5.7
安裝方式:RPM安裝
1、解除安裝系統自帶Mariadb
Centos7 已經不自帶MySQL,自帶內部集成了Mariadb,而安裝MySQL的話會和Mariadb的檔案衝突,所以需要先解除安裝掉Mariadb,再安裝MySQL。
[[email protected] ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[ [email protected] ~]# rpm -qa | grep mariadb
[[email protected] ~]#
2、準備安裝包
連結:https://pan.baidu.com/s/1dLFagL9xEaDo4RygPj7X1g
提取碼:gtv3
3、安裝mysql
3.1 安裝依賴包
yum install -y perl-Module-Install.noarch perl libaio libnuma* net-tools
3.2 rpm 安裝MySQL
cd /usr/local/src/MySql-5.7 #切換到安裝包目錄
下面有命令
[[email protected] MySql-5.7]# rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm
警告:mysql-community-common-5.7.20-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-common-5.7.20-1.e################################# [100%]
[
警告:mysql-community-libs-5.7.20-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-libs-5.7.20-1.el7################################# [100%]
[[email protected] MySql-5.7]# rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.20-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-client-5.7.20-1.e################################# [100%]
[[email protected] MySql-5.7]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.20-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-server-5.7.20-1.e################################# [100%]
rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
3.3 啟動mysql
[[email protected] MySql-5.7]# systemctl start mysqld #啟動
[[email protected] MySql-5.7]# systemctl enable mysqld #開機啟動
[[email protected] MySql-5.7]# systemctl status mysqld #檢視狀態
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2018-11-19 10:43:24 CST; 15s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 5450 (mysqld)
CGroup: /system.slice/mysqld.service
└─5450 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
11月 19 10:43:17 server1 systemd[1]: Starting MySQL Server...
11月 19 10:43:24 server1 systemd[1]: Started MySQL Server.
3.4獲取mysql預設密碼並修改密碼
[[email protected] MySql-5.7]# grep "password" /var/log/mysqld.log
2018-11-19T02:43:20.789934Z 1 [Note] A temporary password is generated for [email protected]: CQ=LgyNzs369
[[email protected] MySql-5.7]# mysql -uroot -pCQ=LgyNzs369
mysql> SET PASSWORD = PASSWORD("Cmzw.2018"); #修改密碼
Query OK, 0 rows affected, 1 warning (0.00 sec)