一、知晓旧密码的情况下:
mysql -u root
mysql> set password for root@localhost = password(‘新密码’);
二、丢失root密码的情况下
mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD(“new password”) WHERE user=‘root’;
mysql> FLUSH PRIVILEGES;