centos 7 安装 mysql 8

开发服务器上安装mysql 8,因为都是内网环境所以变更root密码为简单密码。
根据官网链接 ,执行:

wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm

检查版本:

yum repolist enabled | grep mysql
yum install mysql-community-server

启动:

service mysqld start

检查状态:

service mysqld status
grep 'temporary password' /var/log/mysqld.log

用log中的密码登录:

mysql -uroot -p

变更root的密码(必须先是localhost)

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

变更密码策略默认值为medium

show variables like 'validate_password%';

+————————————–+——–+
| Variable_name | Value |
+————————————–+——–+
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | MEDIUM |
| validate_password.special_char_count | 1 |
+————————————–+——–+

变更root账号的密码为简单策略,并变更root的账户密码:

set global validate_password.policy = low alter user 'root'@'localhost' with mysql_native_password identified by 'simplepassword';
create user 'root'@'%' with mysql_native_password identified by 'simplepassword' ;

创建应用账号和密码:

create user 'foo'@'%' with mysql_native_password identifieid by 'foo_pass';
create database bar;
grant all privileges on bar.* to 'foo'@'%';

说明:
mysql8 默认是caching_sha2_password。可以从show create table mysql.user中的plugin字段的默认值开出来。针对用户的字段更改,不能update mysql.user实现,只能是create user或alter user时加with mysql_native_password。网上的mysql_old_password插件已经不再安装在mysql服务器中(不信可以试试select host, user, plugin from mysql.user where user = 'foo';)。在mysql 5.7之前版本,默认是mysql_native_password。如果使用mysql 8默认的caching_sha2_password会造成mysql小于等于5.7版本的客户端出错:

ERROR 2059 (HY000): Authentication plugin ‘caching_sha2_password’ cannot be loaded: /usr/lib64/mysql/plugin/cach_sha2_password.so: cannot open shared object file: No such file or directory

相关文章
相关标签/搜索