mysql主流版本5.5/5.6/5.7/8.0重置修改密码方法

最近几天来回切换各个Mysql版本重置密码,记录一下各个版本重置密码的方法。

MySql 5.5
SET PASSWORD FOR 'username'@'localhost' = PASSWORD('new_password');
MySql5.6
SET PASSWORD FOR 'username'@'localhost' = 'new_password';
MySql5.7
ALTER USER 'username'@'localhost' IDENTIFIED BY 'new_password';

ALTER USER 'username'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY 'new_password';
MySql8.0
ALTER USER 'username'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY 'new_password';

注意

  • username是数据库账号
  • localhost 是指账号对应的host主机字段值,需要按实际情况填写
  • new_password 新密码
  • mysql_native_password mysql 在8.0+中可以设置密码的插件可以选择的更安全的插件还有caching_sha2_password

你可能感兴趣的:(mysql,mysql,数据库)