Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.15
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
3.继续输入:use mysql,出现错误,如下:
1 2 3
mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
那么需要更改用户密码,输入命令:
alter user ‘root‘@’localhost’ identified with mysql_native_password by ‘amp’;
结果如下:
1 2 3
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'amp';
Query OK, 0 rows affected (0.01 sec)
注:在mysql8版本中更改用户密码需要加入with mysql_native_password,并且要加入;所以一下两种写法都是不对的。 alter user ‘root‘@’localhost’ identified by ‘amp’; alter user ‘root‘@’localhost’ identified with mysql_native_password by ‘amp’