查看數據庫版本命令: mysql --versionmysql
mysql-community-common-8.0.17-1.el7.x86_64.rpmsql
mysql-community-libs-8.0.17-1.el7.x86_64.rpm數據庫
mysql-community-client-8.0.17-1.el7.x86_64.rpm安全
mysql-community-server-8.0.17-1.el7.x86_64.rpm服務器
依次安裝上述RPM包,先後安裝包爲依賴關係。ide
# rpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm # rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm # rpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm # rpm -ivh mysql-community-server-8.0.17-1.el7.x86_64.rpm
mysql 8.0版本的初始密碼默認非空,安裝時自動生成,存儲在/var/log/mysqld.logzhon中。測試
# grep 'temporary password' /var/log/mysqld.log 2019-09-25T06:52:32.788931Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost:~~ aVcrv:9nEnsd~~
修改密碼默認有安全性要求,對密碼複雜度有控制。ui
mysql> alter user 'root'@'localhost' identified by 'redhat'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements mysql> alter user 'root'@'localhost' identified by '1qaz!QAZ'; Query OK, 0 rows affected (0.15 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)
mysql> show databases; mysql> use mysql; mysql> select user,host,plugin from user;
mysql> create user 'wangwang'@'%' identified by '1qaz!QAZ'; Query OK, 0 rows affected (0.08 sec) mysql> grant all on *.* to 'wangwang'@'%'; Query OK, 0 rows affected (0.12 sec) mysql> select user,host,plugin from user;
該帳戶的plugin加密方式爲caching_sha2_password, MySQL 8.0前的客戶端在鏈接 MySQL 8.0服務器時會出現 Authentication plugin 'caching_sha2_password' cannot be loaded 的錯誤(須要更該爲mysql_native_password)。加密
修改加密規則code
mysql> alter user 'wangwang'@'%' identified by '1qaz!QAZ' password expire never; Query OK, 0 rows affected (0.17 sec)
更新用戶密碼
mysql> alter user 'wangwang'@'%' identified with mysql_native_password by '1qaz!QAZ'; Query OK, 0 rows affected (0.04 sec)
保存更改
mysql> flush privileges; Query OK, 0 rows affected (0.05 sec)
查詢信息
mysql> select user,host,plugin from user;
能夠使用Navicat進行測試。