执行代码(当前系统 ubuntu0.18.04.1 ,mysql版本: 5.7.31 )
//通过/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码登录
#mysql -udebian-sys-maint -prEdiryJL********
mysql> use mysql;
mysql> update user set authentication_string=passworD("face") where user='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
Mysql数据库修改密码的代码版本区别:
版本为8.0及以上的
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';
FLUSH PRIVILEGES;
版本为5.7及以上的
update user set authentication_string=passworD("密码") where user='root';
FLUSH PRIVILEGES;
版本为5.7以下的
update user set password=passworD("密码") where user='root';
具体实现步骤图示