如果有root权限,直接在 terminal 下输入 mysql
进入 MySQL 的交互界面:(如果没有root权限,在 terminal 下输入 sudo mysql
)
使用语句 alter user 'root'@'localhost' identified with mysql_native_password by 'YourPassword';
添加密码。
下次即可使用添加的密码登录。
如果有root权限,直接在 terminal 下输入 mysql
进入 MySQL 的交互界面:(如果没有root权限,在 terminal 下输入 sudo mysql
)
使用语句 alter user 'root'@'localhost' identified with mysql_native_password by 'YourPassword';
添加密码。
下次即可使用添加的密码登录。