mysql Ver 8.0.27-0ubuntu0.21.10.1 for Linux on x86_64 ((Ubuntu))
使用sudo登录mysql
Sudo mysql
然后使用以下命令更改密码,密码需要符合mysql的要求
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'NewPassword';
exit;
测试一下
mysql -u root -p
mysql Ver 8.0.27-0ubuntu0.21.10.1 for Linux on x86_64 ((Ubuntu))
使用sudo登录mysql
Sudo mysql
然后使用以下命令更改密码,密码需要符合mysql的要求
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'NewPassword';
exit;
测试一下
mysql -u root -p