### 方法一
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
### 方法二
# /etc/init.d/mysql stop
# /usr/bin/mysqld_safe --skip-grant-tables
# mysql -u root
mysql> set global read_only=1;//(读写属性)
mysql> flush privileges;
mysql> grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;
mysql> flush privileges;
[mysql]修复root无法登陆
最新推荐文章于 2024-04-29 11:42:05 发布