mysql重置root密码 发表于 2017-07-12 | 分类于 Mysql 1,Mysql 密码重置 系统,数据库版本 1234[root@ct7 ~]# more /etc/redhat-releaseCentOS Linux release 7.3.1611 (Core)Server version: 5.7.18 MySQL Community Server (GPL) 修改my.cnf配置文件,添加’skip-grant-tables’ 12345[root@ct7 ~]# vi /etc/my.cnf# read_rnd_buffer_size = 2Mdatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockskip-grant-tables 重启数据库 1systemctl restart mysqld 修改mysql root 用户的密码 12345678910111213141516171819202122[root@ct7 ~]# mysql -urootWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.18 MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set authentication_string = password('pass') where user = 'root';Query OK, 1 row affected, 1 warning (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 1 重启数据库,验证 1234567891011121314151617systemctl restart mysqld[root@ct7 ~]# mysql -u root -ppassmysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.18 MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>