>cat /var/log/mysqld.log |grep password
2020-09-16T02:51:00.561577Z 6 [Note][MY-010454][Server] A temporary password is generated for root@localhost: &qo)k2);v/uE
修改初始密码:
# 查看下
mysql> 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 |
+--------------------------------------+--------+
7 rows inset(0.06 sec)# 设置密码长度最低位数
mysql>set global validate_password.length=6;
Query OK, 0 rows affected (0.01 sec)# 设置密码强度级别
mysql>set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)# 修改密码
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
# 切换数据库
mysql>use mysql
Reading table information for completion oftableandcolumn names
You can turn off this feature to get a quicker startup with-A
Database changed
# 修改host为%,任意ip地址可以访问
mysql>updateusersetuser.Host='%'whereuser.User='root';
Query OK,1row affected (0.03 sec)Rowsmatched: 1 Changed: 1Warnings: 0# 刷新权限
mysql> flush privileges;
Query OK,0rows affected (0.00 sec)
CentOS7安装MySQL 8教程环境介绍安装MySQL安装配置启动MySQL设置root用户密码MySQL远程连接授权环境介绍操作系统:CentOS 7MySQL安装版本:8.0.21 for Linux on x86_64 (MySQL Community Server - GPL)查看MySQL软件是否安装:rpm -qa | grep mysql卸载MySQL:yum remove -y mysql mysql-libs mysql-commonrm -rf /var/l