mysql 8.0修改root密码
1.修改配置文件:进入/etc/mysql/mysql.conf.d/ ,在配置文件mysqld.cnf下添加 skip-grant-tables
2.在终端输入命令:sudo service mysql restart来重新启动mysql服务
3.输入:mysql -u root -p,回车进入mysql(此时不需要密码即可直接进入)
4.输入:use mysql;
5.输入:update user set authentication_string='' where user='root';,将authentication_string 置空;
6.输入:alter user 'root'@'localhost' identified by 'newpassword';,newpassword为要修改的新密码;
此时提示错误:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
输入:FLUSH PRIVILEGES;
再重新alter user 'root'@'localhost' identified by 'newpassword';
此时错误提示为:ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded
,
输入select user,plugin from mysql.user;来查看plugin
这里输入update user set plugin='mysql_native_password' where user='root';将plugin改为以前版本的密码认证方式
然后输入:FLUSH PRIVILEGES;
再重试alter user 'root'@'localhost' identified by 'newpassword';即可修改密码
7.修改完成后输入FLUSH PRIVILEGES;
8. 将第一步的skip-grant-tables注释掉;
9.输入service mysql restart重启mysql
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具