First, the root of the original myql password;
Method One:
Outside the MySQL system, use the Mysqladmin
mysqladmin-u root-p Password "test123" Enter Password: "Enter the original password"
Method Two:
By logging into the MySQL system,
Mysql-uroot-penter Password: "Enter the original password" mysql>use mysql;mysql> update user set Password=password ("test123") where u ser= ' root ';mysql> flush privileges;mysql> exit;
Second, forget the original myql root password;
1. Modify the MySQL configuration file (default is/ETC/MY.CNF) and add a line under [Symbolic-links=0] Skip-grant-tables
2. After saving the configuration file, restart the MySQL service mysqld restart
3, again into the MySQL command line mysql-uroot-p, enter the password when the direct return, will enter the MySQL database, this time according to the general process to modify the root password can be.
mysql-uroot-pmysql> use mysql;mysql> Update user set Password=password ("test123") where user= ' root '; Mysql> Flush privileges;mysql> exit;
5. After the password has been modified, delete the skip-grant-tables in the configuration file.
and restart the MySQL service, the new password will take effect.
Modify the MySQL root password