Micro-Recipe: Ubuntu Mysql Root Password Restoring
Here are the bare bone commands to restore your mysql root password ->
-
/etc/init.d/mysql stop
-
/usr/bin/mysqld_safe –skip-grant-tables &
-
mysql -u root mysql
-
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE User='root';
-
mysql> FLUSH PRIVILEGES;
-
mysql> exit;
Testing if it works ->
-
/etc/init.d/mysql restart
-
mysql -u root -p
-
Enter password:
-
mysql> You win !
Then add a mysql user with all privileges ->
-
mysql -u root -p
-
mysql> GRANT ALL PRIVILEGES ON *.* TO 'login'@'localhost' IDENTIFIED BY 'pass' WITH GRANT OPTION;
-
mysql> FLUSH PRIVILEGES;