
正文
Linux 下忘记mysql 密码
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
ERROR (): Access denied for user 'root'@'localhost' (using password: YES)。
一、停止 mysql 数据库
/etc/init.d/mysqld stop
service mysql stop
/etc/init.d/mysqld stop
service mysql stop
或者直接 kill -9 PID
二、执行命令
mysql_safe --user=mysql --skip-grant-table --skip-networking &
三、使用 root 登录 mysql 数据库
mysql -u root -p
四、更新密码
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
新版本更新
UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root';
五、刷新权限
mysql> FLUSH PRIVILEGES;
六、退出重启
quit;
//重启
/etc/init.d/mysqld restart
//重启02
service mysql start
七、授权远程登录mysql
grant all privileges on *.* to root@'%' identified by "password";
flush privileges;
mysql_safe --user=mysql --skip-grant-table --skip-networking &
mysql -u root -p
四、更新密码
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
新版本更新
UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root';
五、刷新权限
mysql> FLUSH PRIVILEGES;
六、退出重启
quit;
//重启
/etc/init.d/mysqld restart
//重启02
service mysql start
七、授权远程登录mysql
grant all privileges on *.* to root@'%' identified by "password";
flush privileges;
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root';
五、刷新权限
mysql> FLUSH PRIVILEGES;
六、退出重启
quit;
//重启
/etc/init.d/mysqld restart
//重启02
service mysql start
七、授权远程登录mysql
grant all privileges on *.* to root@'%' identified by "password";
flush privileges;
mysql> FLUSH PRIVILEGES;
quit; //重启
/etc/init.d/mysqld restart
//重启02
service mysql start
七、授权远程登录mysql
grant all privileges on *.* to root@'%' identified by "password";
flush privileges;
grant all privileges on *.* to root@'%' identified by "password";
flush privileges;





