MySQL 5.7 数据库的忘记 root 登录密码处理
在 /etc/my.cnf 配置文件中添加 skip-grant-tables 绕开 MySQL 5.7 数据库密码验证
echo skip-grant-tables >> /etc/my.cnf
echo skip-grant-tables >> /etc/my.cnf
/etc/init.d/mysqld restart
直接使用 mysql 命令登录 MySQL5.7 数据库并修改 root 登录密码
mysql
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘password‘;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘password‘;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
使用新密码 password 登录 MySQL5.7 数据库
mysql -uroot -ppassword
删掉 /etc/my.cnf 里的 skip-grant-tables
sed -i -e ‘/skip-grant-tables/d‘ /etc/my.cnf
/etc/init.d/mysqld restart
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
bianruifeng 2020-11-16
云中舞步 2020-11-12
世樹 2020-11-11
暗夜之城 2020-11-11
Coder技术文摘 2020-09-29
huacuilaifa 2020-10-29
Gexrior 2020-10-22
tufeiax 2020-09-03
疯狂老司机 2020-09-08
王艺强 2020-11-17
aydh 2020-11-12
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
xjd0 2020-09-10