mysql -uroot -p
# 登入後
USE mysql;
UPDATE user SET authentication_string = PASSWORD('new_password') WHERE User = 'root';
FLUSH PRIVILEGES;
說明:
authentication_string(舊版為 password)PASSWORD() 為單向加密,不可逆FLUSH PRIVILEGES 重新載入授權表使生效--skip-grant-tables 啟動mysqld --skip-grant-tables & (Linux)skip-grant-tables 後重啟服務mysql -urootskip-grant-tables,正常重啟 MySQLSET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_pass');mysqladmin -u root -p'old_pass' password 'new_pass'ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_pass'; (MySQL 5.7.6+)FLUSH PRIVILEGES 或重啟服務validate_password 插件)