ubuntu20.04上邊部署了一個新的mysql服務,默認沒密碼,想要修改密碼。
使用如下手段
第一種:
ALTER USER 'root'@'localhost' IDENTIFIED BY '密碼';
第二種: update user set authentication_string=password("root") where user='root' and host='localhost';
第三種: mysqladmin -uroot -p 老密碼 password 新密碼
第四種: use mysql; set password for root@localhost = password('root');
驚奇的發現,使用老的修改密碼方式均無效。
查看發現mysql8.0不能再用以前的修改密碼語句。
新語句為:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密碼';