[root@localhost support-files]# systemctl stop mysqld.service
[root@localhost support-files]# mysqld_safe --skip-grant-tables --skip-networking &
[1] 17502
[root@localhost support-files]# 2020-01-18T03:30:30.451790Z mysqld_safe Logging to '/data/mysql/data/localhost.localdomain.err'.
2020-01-18T03:30:30.491899Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/data
[root@localhost support-files]# mysql
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user root@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
[root@localhost support-files]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
Linux从入门到放弃 数据库修改root密码
最新推荐文章于 2024-01-30 11:05:47 发布
本文详细记录了在Linux环境下,通过停止MySQL服务、启动安全模式、重置root用户密码的全过程。首先,使用systemctl命令停止mysqld服务;然后,通过mysqld_safe命令以--skip-grant-tables和--skip-networking参数启动MySQL,进入安全模式;接着,在MySQL命令行中刷新权限并修改root用户的密码;最后,验证新密码是否生效。
706

被折叠的 条评论
为什么被折叠?



