mysql8 修改root密码
mysql8忘记了root密码,需要修改
步奏:
1. <span> 从/etc/my.cnf 配置文件中加入skip-grant-table后正常登陆</span>
,把 localhost和user=root 的 authentication_string设置为空字符串
# systemctl restart mysqld # mysql -u root -p
mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set authentication_string=‘‘ where user=‘root‘; mysql> select Host,User,authentication_string from user; +-----------+------------------+------------------------------------------------------------------------+ | Host | User | authentication_string | +-----------+------------------+------------------------------------------------------------------------+ | localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | root | | +-----------+------------------+------------------------------------------------------------------------+ 4 rows in set (0.00 sec) mysql> flush privileges; mysql> exit
2. 把 <span>skip-grant-table 去掉 重启mysql后,这时候 用空字符串可以登录mysql了</span>
# systemctl restart mysqld # mysql -u root -pmysql>
3. 再修改密码
mysql> alter user ‘root‘@‘localhost‘IDENTIFIED BY ‘MyNewPas‘; mysql> flush privileges;
修改完成.
相关推荐
lpfvip00 2020-10-07
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