环境 ubuntu20 、 sudo apt install mysql-server
如果以前设置有密码:
use mysql;
update user set authentication_string='' where user='root'; --将字段置为空
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
--修改密码为123456
如果以前没有设置密码:
alter user 'root'@'localhost' identified with mysql_native_password by '123456';