方法3: 用UPDATE直接編輯user表 mysql -u root mysql> use mysql; mysql> update user SET Password = PASSWord('newpass') where user = 'root'; mysql> FLUSH PRIVILEGES;
在丟失root密碼的時(shí)候,可以這樣:
mysqld_safe --skip-grant-tables& mysql -u root mysql mysql> update user SET password=PASSWord("new password") where user='root';