Skip navigation.
Home
Making the world a better place through software!

Ubuntu MySQL lost root password

  • : Function split() is deprecated in /var/www/drupal-5.1/modules/filter/filter.module on line 1190.
  • : Function split() is deprecated in /var/www/drupal-5.1/modules/filter/filter.module on line 1190.
  • : Function split() is deprecated in /var/www/drupal-5.1/modules/filter/filter.module on line 1190.
  • : Function split() is deprecated in /var/www/drupal-5.1/modules/filter/filter.module on line 1190.

If you have lost or forgotten your MySQL root password on Ubuntu (or Debian) then the following will help you reset it without having to shut the server down.

Use the privilidged debian-sys-maint MySQL user to reset the user root. To find debian-sys-maint's MySQL password:

root@lmmrtech.com:/# cd /etc/mysql
root@lmmrtech.com:/etc/mysql# sudo cat debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = NoWayBud
socket   = /var/run/mysqld/mysqld.sock

Use the password reported here to connect into MySQL and set a new root password:

root@lmmrtech.com:/etc/mysql# mysql -u debian-sys-maint -p
Enter password: NoWayBud
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.0.45-Debian_1ubuntu3.1-log Debian etch distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('MyNewPasswd')