Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'

Tags:

mysql

root

debian

Longtime reader of Stackoverflow, first time submitting a question.

I had to hardware-reboot my dev laptop a few nights ago for various reasons. When i brought it back up i realized that mysqld were no longer accessible. I usually connect with root on a local dev machine. I could not start/stop it through the init-scripts as usual either and so I turned to various search engines as always. After consulting Google, Bing and Duckduckgo.com I still could not find a solution on the problem. I found solutions to similar problems but all involved changing the auto-generated password for debian-sys-maint and login as root to set a new one but since I cannot login as root either this does not solve my problem.

Does anyone know of any other solution-candidates for this dilemma?

error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)' .

like image 502
dVw Avatar asked Jan 20 '12 07:01

dVw


2 Answers

I just got the same error after I restored mysql database like so:

mysql -h localhost -u root -p < mysql.backup.sql

mysql.backup.sql file comes from another server.

The problem seems to originate from the different password stored in /etc/mysql/debian.cnf in target and source systems. I copy/pasted the password line from source system's debian.cnf file to the file in target system. Then I was able to restart mysqld without any problems.

Note: I had to do killall mysqld before I could do a restart.

like image 156
Can Kavaklıoğlu Avatar answered Nov 12 '22 20:11

Can Kavaklıoğlu


Sounds like you might have trashed the tables in the database ("mysql") that holds the credentials for accessing all the databases. Do you see anything in the MySQL logs (/var/log/mysql) that indicates a problem?

If there is corruption the approach to trying to fix it will depend on your storage engine. Are you using MyISAM (the default)? If so, try turning off the daemon and using myisamchk to attempt a repair.

If you can't repair, you will likely have to restore from backups (you have backups, right?) or reinitialize MySQL (probably just reinstalling the package through APT is easiest).

You might try over at ServerFault too for more suggestions from experienced sysadmins.

P.S.- if you have system super user access, you can reset the MySQL root password even if you can't login to MySQL, albeit through a somewhat convoluted procedure.

like image 40
Conrad Shultz Avatar answered Nov 12 '22 20:11

Conrad Shultz