1 检查mySql的运性状态
service mysqld status

2 停止mySql的运性
service mysqld stop
3 修改mysql的配置文件my.conf
添加 skip-grant-tables
vi /etc/my.cnf

4 重启数据库
service mysqld start
5 进入mySql数据库
mysql -u root
6 修改密码
use mysql;
update mysql.user set authentication_string=password('root_password') where user='root';
root_password替换成你想要的密码
7 删掉第三步的配置,并重启服务器
mysql -u root -p
网友评论