A few months ago, I migrated my web server from a 500MHz (or was it 450MHz?) Pentium III to a dual-450MHz Pentium II server after the 6GB hard drive died after a power surge.
I reinstalled Ubuntu 6.06 from scratch and installing Apache, PHP and MySQL manually. I then restored the database with one of my backup scripts. I didn’t realise it at the time, but the debian-sys-maint user on the old server had a different randomly-generated password to the one on the new server. When I restored the backup, the user was given the old password.
So, whenever I tried to install a Debian package that tried to automatically configure MySQL (like mediawiki) it would fail to set anything up, as it was always trying to use the wrong password. Luckily, I’ve found out how to fix that.
The password dpkg uses for the debian-sys-maint user is located in the file /etc/mysql/debian.cnf. That file is protected from prying eyes, so in order to access it, you’ll need to use sudo:
sudo less /etc/mysql/debian.cnf
In that file, you’ll see two or so lines containing something like the following:
password = AaBbCcDdEeFfGgHh
That part to the right of the = sign is the password dpkg wants to use for updating your MySQL database. Believe it or not, that is the actual password in clear text. Not encrypted. Keep that password handy, we’re going to need it soon.
Open your preferred method of administering your MySQL database. Typically that will be either MySQL Administrator or phpMyAdmin. When you are in it, log on and go to the spot where you manage users. In phpMyAdmin, this section is called privileges.
Find the debian-sys-maint user. Then use the function to change the password. The password you set it to will be the one you found in /etc/mysql/debian.cnf, similar in format to AaBbCcDdEeFfGgHh. Save changes.
Now you should be all done. Try apt-get installing something.


Thank you, Jeremy. My mysql database was accidentally overwritten with different passwords for debian admin. Your write-up was what I used to fix it.