本文主要介紹如何經過官方提供的RPM包安裝mysql5.7, 安裝前,請前往MySQL官網下載mysql5.7的RPM安裝包。我下載的是rpm的集合包:mysql-5.7.17-1.el7.x86_64.rpm-bundle.tarnode
#檢查 [root@ares ~]# rpm -qa|grep mariadb mariadb-libs-5.5.35-3.el7.x86_64 #卸載 [root@ares ~]# rpm -e mariadb-libs-5.5.35-3.el7.x86_64 --nodeps
其中,安裝mysql-server, 須要如下幾個必要的安裝包:mysql
安裝上面四個包須要libaio的依賴, 須要經過如下命令安裝:sql
#安裝libaio [root@ares mysql-5.7.17-1.el7.x86_64.rpm-bundle]# yum -y install libaio
[root@ares mysql-5.7.17-1.el7.x86_64.rpm-bundle]# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm mysql-community-libs-5.7.17-1.el7.x86_64.rpm mysql-community-client-5.7.17-1.el7.x86_64.rpm mysql-community-server-5.7.17-1.el7.x86_64.rpm warning: mysql-community-common-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-common-5.7.17-1.e################################# [ 25%] 2:mysql-community-libs-5.7.17-1.el7################################# [ 50%] 3:mysql-community-client-5.7.17-1.e################################# [ 75%] 4:mysql-community-server-5.7.17-1.e################################# [100%] [root@ares mysql-5.7.17-1.el7.x86_64.rpm-bundle]#
[root@ares mysql-5.7.17-1.el7.x86_64.rpm-bundle]mysqld --initialize #在/var/log/mysqld.log生成隨機密碼
[root@ares mysql]# chown mysql:mysql /var/lib/mysql -R
#啓動mysql數據庫 [root@ares mysql]# systemctl start mysqld.service # 到/root目錄下尋找.mysql_secret文件 [root@ares ~]# cat .mysql_secret # Password set for user 'root@localhost' at 2017-04-01 03:08:05 =%Tyw*p&(wb # 更改root用戶密碼,新版的mysql在第一次登陸後更改密碼前是不能執行任何命令的 [root@ares ~]# mysql -u root -p '=%Tyw*p&(wbl'
#更改密碼: mysql> set password=password('Love88me'); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; mysql> grant all privileges on *.* to root@'%' identified by 'Love88me' with grant option; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)
#開放3306端口號 [root@ares ~]# firewall-cmd --permanent --add-port=3306/tcp #從新加載防火牆 [root@ares ~]# firewall-cmd --reload # 查看防火牆配置,能夠看出3306已經在例外了 [root@ares ~]# firewall-cmd --list-all public (default, active) interfaces: enp0s3 enp0s8 sources: services: dhcpv6-client ftp ssh ports: 3306/tcp masquerade: no forward-ports: icmp-blocks: rich rules:
新版的mysql數據庫下的user表中已經沒有Password字段了,而是將加密後的用戶密碼存儲於authentication_string字段數據庫