I forgot the MySQL root password. I forgot the mysql password Based on Ubuntu 12.04 LTS. The solution found on the internet is recorded here. Edit the mysql configuration file/etc/mysql/my. cnf at www.2cto.com and add a line "skip-grant-tables" under [mysqld ".
Restart mysql service abbuggy @ abbuggy-ubuntu :~ $ Sudo service mysql restartmysql stop/waitingmysql start/running, process 18669 enter the mysql management command line with an empty password, and switch to the mysql database. Abbuggy @ abbuggy-ubuntu :~ $ Mysql Welcome to the MySQL monitor. commands end with; or \ g. mysql> use mysqlDatabase changed execute update user set password = PASSWORD ("new_pass") where user = 'root'; reset the password to new_pass. Exit database management. Www.2cto.com 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 back to vim/etc/mysql/my. cnf: 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. Abbuggy @ abbuggy-ubuntu :~ $ Mysql-uroot-pnew_passWelcome to the MySQL monitor. Commands end with; or \ g. mysql>