quarta-feira, 4 de novembro de 2009

MySQL: “Access denied for user ‘debian-sys-maint’@’localhost’” « RU-FI-OOOOOH!

MySQL: “Access denied for user ‘debian-sys-maint’@’localhost’” « RU-FI-OOOOOH!: "RU-FI-OOOOOH!

Sohail Mirza, standing in for Peter.
MySQL: “Access denied for user ‘debian-sys-maint’@'localhost’”

with 3 comments

For all you Ubuntu/MySQL developers out there, have you ever seen the following?

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

So, what is this “debian-sys-maint” user? Well, this MySQL user is created for the Ubuntu to be able to start/stop the database and to carry out other maintenance operations.

Sounds well enough, but then why do I keep running into the “access denied” problem for this user? Well, the issue is that with each update to MySQL, the user’s password in the database is overwritten. Ubuntu seems to go to the file /etc/mysql/debian.cnf in order to find this user’s password, but obviously the password is out of sync after the update has been applied.

As a result of this behaviour, I’ll run into the “access denied” problem every so often. Thankfully, the solution to this issue is fairly simple.

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

neo@thematrix:~$ sudo cat /etc/mysql/debian.cnf

The contents of the file should look something like the following:

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

See that password? That’s what we’re looking for!

Next, we want to issue a command to MySQL that tells 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 you had originally set:

neo@thematrix:~$ mysql -u root -p <password>

Issue the GRANT command now to grant those permissions:

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

Voila! If you restart MySQL, you’ll find that you should no longer be getting the “access denied” error message.

neo@thematrix:~$ 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.

Bear in mind, because we just switched the password, and the change hasn’t been affected yet, you may need to kill the MySQL server processes in order to get MySQL to shut down at all.

Possibly related posts: (automatically generated)

* MySQL create an Anonymous or limited access only account
* Connecting from windows to MYSQL on Ubuntu

Written by Sohail Mirza

January 16, 2009 at 6:51 pm

Posted in Development, Ubuntu

Tagged with debian, error, mysql, Ubuntu
« dpkg problems relating to ‘cups’ in Ubuntu
Riding Tokyo »
3 Responses

Subscribe to comments with RSS.

1.

Right tf on!

Oogliby

February 11, 2009 at 8:44 am
Reply
*

I see this is an older post, but just ran into this, myself. Reseting the debian-sys-maint password in mysql to match the debian.cnf file takes care of it – but do you know if there is a bug filed against this?

No other mysql passwords are reset during updates – so this seems odd to me.

Jere

October 16, 2009 at 11:47 am
Reply
o

In my research of the solution, I can’t say I did come across a bug filed for this issue.

Sohail Mirza

October 16, 2009 at 11:57 am


Leave a Reply
Click here to cancel reply.

Name (required)

E-mail (will not be published) (required)

Website

Notify me of follow-up comments via email.
Who am I?
Sohail Mirza is a software professional with a background in both design and development. He blogs about both, as well as other matters, real & virtual.
Search for:
Top Posts

* Helpful Hints - Apple Movie Trailers download using Firefox, Greasemonkey, and User Agent hack
* Star Trek beams onto Apple Movie Trailers
* Helpful Hints - Downloading HD Trailers from Apple Trailers
* MySQL: 'Access denied for user 'debian-sys-maint'@'localhost''
* Helpful Hints - Running multiple instances of Firefox

Browse a category
My del.icio.us

* BBC NEWS | Middle East | Israel 'cuts Palestinian water'
* Asia Sentinel - Pakistan's Persecuted Minority
* Michael Jordan's Top 23 Moments
* Why AI is a dangerous dream - opinion - 01 September 2009 - New Scientist
* Build an Insanely Great Web Service - ReadWriteStart
* BBC NEWS | Middle East | Gaza sewage 'a threat to Israel'
* Django Con High Performance Django
* PreciseJava.com - The path to improvement
* Django-Socialauth - GitHub
* Andy Kessler: Why AT&T Killed Google Voice - WSJ.com

Archives

Blog at WordPress.com. — Journalist theme by Lucian E. Marin"

Nenhum comentário: