赞
踩
忘记MySQL连接密码
[root@localhost ~]# systemctl stop mysqld
[root@localhost ~]# mysqld_safe --skip-grant-tables --skip-networking &
mysqld_safe
是一个脚本,用于以安全模式启动MySQL服务器。这种方式启动MySQL时,它会检查一些基本条件,并在出现问题时尝试修复。--skip-grant-tables
参数跳过了权限表的检查,这意味着在启动时MySQL不验证任何用户凭据,任何人都可以无需密码连接到MySQL服务器。--skip-networking
参数则禁用了MySQL监听任何网络接口,只允许本地Unix套接字连接。这样做是为了增加安全性,防止在跳过权限检查时外部用户通过网络访问数据库。mysql.user
表中root
用户的密码。update mysql.user set password=PASSWORD('123456') where user='root' and host='localhost';
flush privileges;
忘记MySQL连接密码
net stop mysql
忘记bin文件路径可以跳过win+r输入services.msc找到MySQL右击属性查看,最好提前复制下来
mysqld --skip-grant-tables在8.0及以上版本不使用了
mysqld --console --skip-grant-tables --shared-memory
必须是另外一个cmd窗口哦
上一个跳过权限表验证的窗口也不要关闭
update user set authentication_string='' where user='root';
alter user 'root'@'localhost' identified by '123';
flush privileges;
alter user 'root'@'localhost' identified by '123';
flush privileges;
net start mysql
#不建议-p参数后直接加密码,这里为了展示方便
mysql -uroot -p123
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。