mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码
grep ‘temporary password’ /var/log/mysqld.log

然后执行 mysql -uroot -p ,输入上面的到的密码进入,用该密码登录后,必须马上修改新的密码,不然会报如下错误:
mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
设置新密码,密码需要设置复杂一些
mysql> alter user ‘root’@’localhost’ identified by ‘IqWYF(TD2020’;
Query OK, 0 rows affected (0.00 sec)
正文完