linux中Mysql忘记root密码如何登陆 1.关闭mysql服务 systemctl stop mysqld netstat -tuNLP|grep mysqld 2.进入配置文件添加一条命令 [mysqld] skip
1.关闭mysql服务
systemctl stop mysqld
netstat -tuNLP|grep mysqld
2.进入配置文件添加一条命令
[mysqld]
skip-grant-tables #以安全模式启动
重新启动服务
systemctl start mysqld
4.无密码模式登陆
mysql -uroot
5. 5.7版本以后passWord字段没有,更改为authentication_string
show databases;
use mysql;
show tables;
desc user;
update mysql.user set authentication_string=password(‘xxx‘) where user=‘root‘ ;
flush privileges;
修改完毕后将配置文件中添加的语句注释掉,并重启服务
vim /etc/my.cnf
#skip-grant-tables
systemctl restart mysqld
新密码重新登陆后出现问题
show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
#意思是必须使用alter user命令重新设置密码
mysql> alter user [email protected] identified by ‘XXXXXX‘;
flush privileges;
MySQL系列-修改root密码
--结束END--
本文标题: MySQL系列-修改root密码
本文链接: https://www.lsjlt.com/news/7649.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
2024-05-08
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0