方法1:用SET PASSWORD命令,具體更新密碼步驟如下:c:>mysql -u rootmysql>set password for "root"@"localhost"=password("newpasswd");mysql>set password for "root"@"%"=password("newpasswd"); //本條可選透過以上設定,root的密碼將變為newpasswd這樣就完成了根使用者root密碼的設定工作。方法2:用mysqladminmysqladmin -u root password "newpass"如果root已經設定過密碼,採用如下方法 mysqladmin -u root password oldpass "newpass"方法3: 用UPDATE直接編輯user表mysql -u root mysql> use mysql; mysql> UPDATE user SET Password = PASSWORD("newpass") WHERE user = "root"; mysql> FLUSH PRIVILEGES;在丟失root密碼的時候,可以這樣mysqld_safe --skip-grant-tables& mysql -u root mysql mysql> UPDATE user SET password=PASSWORD("new password") WHERE user="root"; mysql> FLUSH PRIVILEGES;
方法1:用SET PASSWORD命令,具體更新密碼步驟如下:c:>mysql -u rootmysql>set password for "root"@"localhost"=password("newpasswd");mysql>set password for "root"@"%"=password("newpasswd"); //本條可選透過以上設定,root的密碼將變為newpasswd這樣就完成了根使用者root密碼的設定工作。方法2:用mysqladminmysqladmin -u root password "newpass"如果root已經設定過密碼,採用如下方法 mysqladmin -u root password oldpass "newpass"方法3: 用UPDATE直接編輯user表mysql -u root mysql> use mysql; mysql> UPDATE user SET Password = PASSWORD("newpass") WHERE user = "root"; mysql> FLUSH PRIVILEGES;在丟失root密碼的時候,可以這樣mysqld_safe --skip-grant-tables& mysql -u root mysql mysql> UPDATE user SET password=PASSWORD("new password") WHERE user="root"; mysql> FLUSH PRIVILEGES;