2020-10-07T03:52:30.076236Z 1 [Note] A temporary password is generated for root@localhost: Ac:y#Dtoc0O2
# 输入密码 Ac:y#Dtoc0O2 进入mysql [root@VM-4-5-centos ~]# mysql -uroot -pAc:y#Dtoc0O2 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.32
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h'forhelp. Type '\c' to clear the current input statement.
mysql> # 输入初始密码,此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库: mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '数据库密码';
# 这里有个问题,新密码设置的时候如果设置的过于简单会报错 # 原因是因为MySQL有密码设置的规范,具体是与validate_password_policy的值有关 # 解决方法就是修改密码为规范复杂的密码 mysql> set global validate_password_policy=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_length=1; Query OK, 0 rows affected (0.00 sec)
# 操作完成上面的,现在还不能用可视化的客户端进行连接,需要我们进行授权 mysql> grant all on *.* to root@'%' identified by '数据库密码'; Query OK, 0 rows affected, 1 warning (0.00 sec)