/etc/init.d/mysql restart

 vi /etc/my.cnf 
       [mysqld]
 增加 skip-grant-tables
重启 mysql服务
use mysql
 
update user set password=password("123456") where user="root"; 
 
flush privileges; 
 
 
OK 推出还原配置文件。
或者
Linux下,运行 /usr/local/mysql/bin/mysqld_safe --skip-grant-tables & 
/usr/local/mysql/bin/mysql -u root -p 
>use mysql
>update mysql.user set password=password("新密码") where user="root"; 
>flush privileges;