[root@kvm6 ~]# /etc/init.d/mysqld stop Stopping mysqld: [ OK ]
mysqld_safe 跳過 grant tables,因為接著要下命令,所以讓其背景執行。
[root@kvm6 ~]# mysqld_safe --skip-grant-tables & [1] 30343 [root@kvm6 ~]# 190520 20:21:32 mysqld_safe Logging to '/var/log/mysqld.log'. 190520 20:21:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@kvm6 ~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.49 MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2016, 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> 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 password=password("123qwe") where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
mysql> quit Bye
[root@kvm6 ~]# /etc/init.d/mysqld restart 190520 20:22:55 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended Stopping mysqld: [ OK ] Starting mysqld: [ OK ] [1]+ Done mysqld_safe --skip-grant-tables