MySQL系列-修改root密码
linux中mysql忘记root密码如何登陆
1.关闭mysql服务
systemctl stop mysqld netstat -tunlp|grep mysqld
2.进入配置文件添加一条命令
[mysqld] skip-grant-tables #以安全模式启动
3.重新启动服务
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;
6.修改完毕后将配置文件中添加的语句注释掉,并重启服务
vim /etc/my.cnf#skip-grant-tables systemctl restart mysqld
7.新密码重新登陆后出现问题
show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
#意思是必须使用alter user命令重新设置密码
mysql> alter user identified by ‘XXXXXX‘; flush privileges;
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11