I did an apt-get upgrade from one version of Debian to another – I think it was etch to lenny.

Upon restarting the box, mysql wouldn’t respond.

hq-lnx-001:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
/usr/bin/mysqladmin: connect to server at ‘localhost’ failed
error: ‘Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)’
hq-lnx-001:~# ERROR 1045 (28000): Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)

debian-sys-maint is Debian’s user for interacting with MySQL. In order to rebuild it, you need to –skip-grant-tables. You can’t do this just running mysqld, you need to edit your my.cnf file.

hq-lnx-001:~# nano /etc/mysql/my.cnf

Image Credit: torkildr