方法1: 用SET PASSWORD命令
MySQL -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
方法2:用mysqladmin
mysqladmin -u root password "newpass"
方法3: 用UPDATE直接编辑表user
mysql -u root mysql> use mysql; mysql> UPDATE user SET password = PASSWORD('newpass') WHERE user = 'root'; mysql> FLUSH PRIVILEGES;