1、关闭mysql
/etc/init.d/mysqld stop
2、启动mysql不加载授权表
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &
这时进入mysql不需要密码
#mysql -uroot
mysql>use mysql;
mysql>update user set Password=password('!@#,abc354') where User='root';
把mysql密码修改为!@#,bac354
3、重启mysql
/etc/init.d/mysqld restart
用新密码进入mysql
#mysql -uroot -p!@#,abc354
本文出自 “linux运维” 博客,请务必保留此出处http://linux008.blog.51cto.com/2837805/662370