登录
- 打开Terminal
- 输入
mysql -uroot -p
- 输入密码(输入时不显示)
- 登录成功
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 55
Server version: 8.0.15 MySQL Community Server - GPL
重置密码
- 使用mysql数据库:
use mysql;
- 将密码清空:
update user set authentication_string='' where user='root';
- 刷新:
flush privileges;
设置密码
- 将密码设置为“123456”:
ALTER user 'root'@'localhost' IDENTIFIED BY '123456';
- 刷新:
flush privileges;
- 退出mysql:
quit;
- 退出Terminal:
exit