mysqld_safe --skip-grant-tables --skip-networking &
–skip-grant-tables 关闭权限表验证
–skip-networking 关闭MySQL的TCP/IP连接方式,只允许本地sock连接
[root@localhost mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 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> alter user root@'%' identified by '123123';
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.01 sec)
mysql> alter user root@'%' identified by '123123';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@localhost mysql]# mysqld_safe &
[2] 23706