1、修改MySQL的登录设置:
在[mysqld]的段中加上的skip-grant-tables # sed -i ‘/\[mysqld\]/a\skip-grant-tables ‘ /etc/my.cnf
2、重新启动mysqld # service mysqld restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS!
3、登录并修改MySQL的root密码 # /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.19 Source distribution
Copyright (c) 2000, 2014, 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.
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 ( ‘doiido‘ ) WHERE User = ‘root‘ ;
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0