In Linux, The MySQLroot password is forgotten Based on Ubuntu12.04LTS.
The solution for forgetting the MySQL root Password in Linux is based on Ubuntu 12.04 LTS.
The solution for forgetting the MySQL root Password in Linux is based on Ubuntu 12.04 LTS.
Forget the mysql password. The solution found on the internet is recorded here.
Edit the mysql configuration file/etc/mysql/my. cnf and add a line "skip-grant-tables" under [mysqld ".
Restart mysql Service
@ Ubuntu :~ $ Sudo service mysql restart
Mysql stop/waiting
Mysql start/running, process 18669
Enter the mysql management command line with an empty password and switch to the mysql database.
@ Ubuntu :~ $ Mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Mysql> use mysql
Database changed
Run the update user set password = PASSWORD ("new_pass") where user = 'root' command to reset the password to new_pass. Exit database management.
Mysql> update user set password = PASSWORD ("new_pass") where user = 'root ';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4 Changed: 0 Warnings: 0
Mysql> quit
Return to vim/etc/mysql/my. cnf and comment out or delete the added "skip-grant-tables" line.
Restart the mysql service sudo service mysql restart again and log on with the new password. The change is successful.
@ Ubuntu :~ $ Mysql-uroot-pnew_pass
Welcome to the MySQL monitor. Commands end with; or \ g.
Mysql>