MySQL: “Access denied for user ‘debian-sys-maint’@’localhost’”

I recently migrated one of our MySQL servers (Simply by using rsync) and afterwards when restarting the MySQL server I was faced with:

admin@db:~$ sudo /etc/init.d/mysql restart
* Stopping MySQL database server mysqld <strong>[fail]</strong>
* Starting MySQL database server mysqld [ OK ]
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: '<strong>Access denied for user 'debian-sys-maint'@'localhost'</strong> (using password: YES)'

This MySQL user is created for Ubuntu to be able to start/stop the database and to preform other maintenance operations.

The issue is that with each update to MySQL, the user’s password in the database is overwritten.  Ubuntu searches the file /etc/mysql/debian.cnf in order to find this user’s password, but obviously the password was out of sync after copying the databases from the old database server.

First, check the contents of the /etc/mysql/debian.cnf file:

admin@db:~$sudo cat /etc/mysql/debian.cnf

The contents of the file should look something like the:

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
<strong>password = PASSWORD</strong>
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
user     = debian-sys-maint
<strong>password = PASSWORD</strong>
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

The PASSWORD   is what we’re looking for.

Next, you will want to issue a command to MySQL to tell it to grant the debian-sys-maint user all necessary privileges using the new password.

Login to your MySQL server using your root account and the root password:

admin@db:~$ mysql -u root -p

Issue the GRANT command now to grant those permissions:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'PASSWORD';

Restart MySQL, you should no longer be getting the “access denied” error message.

admin@db:~$ sudo /etc/init.d/mysql restart
* Stopping MySQL database server mysqld [ OK ]
* Starting MySQL database server mysqld [ OK ]
* Checking for corrupt, not cleanly closed and upgrade needing tables.

You may need to kill the MySQL server processes in order to get MySQL to shut down.

VN:F [1.9.17_1161]
Rating: 7.0/10 (2 votes cast)
MySQL: “Access denied for user ‘debian-sys-maint’@'localhost’”, 7.0 out of 10 based on 2 ratings
Share
You can leave a response, or trackback from your own site.

12 Responses to “MySQL: “Access denied for user ‘debian-sys-maint’@’localhost’””

  1. Aldo Mcgurk says:

    Keep working ,splendid job!

  2. Wentworth says:

    I dont agree with this completely but it brings up some great points.

  3. Anonymous says:

    Thanks for posting this. Helped me out big time. Thanks!

  4. Rico Rappleye says:

    Great post.

  5. Good post, adding it to my own blog today, thanks.

  6. Kristie Zamacona says:

    Posted your page, MySQL: “Access denied for user ‘debian-sys-maint’@’localhost’” | Mike Johnson’s Personal Blog on digg. Regards, Kristie Zamacona

  7. Butch says:

    outstanding post!

  8. Bilotti says:

    Hello very nice web site!! Man ..

  9. Castagnier says:

    Thanks a lot for this article.

  10. Hession says:

    Awesome things here. I’m very satisfied to look at your article.

Leave a Reply

Comments links could be nofollow free.

Twitter Delicious Facebook Digg Stumbleupon Favorites More