Linux下mysql忘记root密码

/etc/my.conf的[mysqld]段加上skip-grant-tables

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
old_passwords=1
skip-grant-tables

重启mysql服务就可以更新user标里面的password了
update mysql.user set password = password(‘root’) where user=root
就可以,然后还原/etc/my.conf