发现会报plugin caching_sha2_password错误。这是因为MySQL8.0密码策略默认为caching_sha2_password。与5.7有所不同。
•进入MySQL数据库查询user表信息
mysql> use mysql;
Database changed
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| linuxidc-mp | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)
mysql>
发现确实是caching_sha2_password
•依次执行下面语句
mysql> ALTER USER 'linuxidc-mp'@'%' IDENTIFIED BY 'linuxidc@linuxidc.com' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.04 sec)
mysql> ALTER USER 'linuxidc-mp'@'%' IDENTIFIED WITH mysql_native_password BY 'linuxidc@linuxidc.com';
Query OK, 0 rows affected (0.05 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql>
再次登录就可以登录成功了。
第8步:编码
mysql> show variables like '%character%';
+--------------------------+--------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
+--------------------------+--------------------------------+
8 rows in set (0.01 sec)
mysql>
MySQL8.0默认就是utf8mb4编码,无需更改。
OK 至此 Mysql安装配置完毕;
全流程操作记录
[root@VM_0_10_centos ~]#
[root@VM_0_10_centos /]# cd /usr/local/mysql/
[root@VM_0_10_centos mysql]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
--2018-08-04 10:29:39-- https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.219.33.198
Connecting to repo.mysql.com (repo.mysql.com)|23.219.33.198|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25820 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-1.noarch.rpm’
100%[==========================================================================>] 25,820 112KB/s in 0.2s
2018-08-04 10:29:40 (112 KB/s) - ‘mysql80-community-release-el7-1.noarch.rpm’ saved [25820/25820]
[root@VM_0_10_centos mysql]# ll
total 28
-rw-r--r-- 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
[root@VM_0_10_centos mysql]# yum -y localinstall mysql80-community-release-el7-1.noarch.rpm
Loaded plugins: fastestmirror, langpacks
Examining mysql80-community-release-el7-1.noarch.rpm: mysql80-community-release-el7-1.noarch
Marking mysql80-community-release-el7-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved