Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access denied for user debian-sys-maint

I have had problem with mysql. I tried to execute this:

echo "show databases" | mysql -B -N 

But I got:

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

But when I exec:

/etc/init.d/mysql restart  

I got an 'OK'.

I did

GRANT ALL PRIVILEGES on *.* TO debian-sys-maint@localhost IDENTIFIED BY PASSWORD 'your password' WITH GRANT OPTION; FLUSH PRIVILEGES; 

where password is from /etc/mysql/debian.cnf. But it didn't help. (of course I flushed priv and restarted mysql).

like image 526
Bartosz Kowalczyk Avatar asked Jul 25 '12 07:07

Bartosz Kowalczyk


2 Answers

That’s because Debian has a MySQL account debian-sys-maint used for switching on/off and checking status. The password for that user should be the same as stored in /etc/mysql/debian.cnf. The file looks like this:

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

If the password doesn't match (for example because you changed it manually) the init script won't work anymore. You should set the password according to the file. So

mysql -u root -p # Then type MySQL root password GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<password>'; 
like image 151
Omesh Avatar answered Oct 02 '22 15:10

Omesh


The problem is, your GRANT statement uses IDENTIFIED BY PASSWORD clause, and in this case mysql expect to get a hashed password, not a plaintext one.

Use IDENTIFIED BY 'your password' instead, if you wish to supply a plaintext password.

like image 43
poncha Avatar answered Oct 02 '22 13:10

poncha