mysql.server stopmysqld_safe --skip-grant-tablesmysql -uroot -pUPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;这里需要注意一点,MySQL5.7版本字段名换了,Password改为authentication_string即可,即:
UPDATE mysql.user SET authentication_string=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;mysql.server start
mysql -uroot -pnewpassword