I edited deian.cnf to change the password of mysql (ubuntu server)
sudo vi /etc/mysql/debian.cnf
I change
user=debian-sys-maint password=*
to
user=debian-sys-maint
password=mypassword
then I tried to enter console of mysql
mysql -udebian-sys-maint -p
and inputed password ‘mypassword’
it reported
mysql error 1045(280000) access denied for user 'debian-sys-maint '@' localhost using password 'yes'
I tried to remove mysql and reinstall, the error is same.
Your comment welcome
asked Aug 7, 2013 at 19:27
1
The error message tell you that, your password is wrong or the account debian-sys-maint
has no access to the database on host localhost
.
If you are sure your password is correct you should grant all privileges like this:
login as root first
mysql -u root -p <password>
then, grant full permissions:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'your password';
restart mysql and see if the error message is gone.
answered Aug 7, 2013 at 19:59
AchuAchu
20.9k15 gold badges78 silver badges101 bronze badges
By default root does not have a password and so you need not append -p at the end. simply type
mysql -u root.
To reset the password, use mysqladmin -u root password [newpassword]
answered Mar 5, 2014 at 18:47
SingularitySingularity
8211 gold badge7 silver badges7 bronze badges
Most easy way to restoring the debian-sys-maint user, is to reconfigure package mysql-server-5.5. That if you know the password for the root user of MySQL, you can try to restore the user and its password in /etc/mysql/debian.cnf.
sudo dpkg-reconfigure mysql-server-5.5
NOTE: if you cannot stop mysql pid, just run sudo killall mysqld
. This is needed for reconfiguring the mysql-server-5.5.
answered Mar 6, 2015 at 19:30
shgnIncshgnInc
3,4334 gold badges26 silver badges29 bronze badges
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)’ .
asked Jan 20, 2012 at 7:42
1
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.
answered Feb 24, 2013 at 18:05
Can KavaklıoğluCan Kavaklıoğlu
4871 gold badge7 silver badges12 bronze badges
2
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.
answered Jan 20, 2012 at 8:03
Conrad ShultzConrad Shultz
8,7382 gold badges30 silver badges33 bronze badges
3
Skip to content
Access denied for user debian-sys-maint — ошибка которая появляется при пароле системного пользователя debian-sys-maint с которым MySQL по какой-то причине не может получить доступ к таблицам баз данных. Часто такие ошибки возникают при настройке репликации MySQL — например, при настройке Galera Cluster.
Следствие ошибки часто — невозможность остановить или перезапустить сервер баз данных. Чтобы исправить ошибку достаточно обносить пароль системного пользователя debian-sys-maint и привести его в соответствие тому, что задан в файле/etc/mysql/debian.cnf
Полностью ошибка может выглядеть так:
Got error: 1045: Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES) while connecting to the MySQL server
Просмотреть файл можно при помощи less
less /etc/mysql/debian.cnf
[client]
host = localhost
user = debian-sys-maint
password = Fae4aekeeShiemei6Ohp
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
user = debian-sys-maint
password = Fae4aekeeShiemei6Ohp
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
Затем нужно авторизоваться в консоли сервера баз данных с правами пользователя root и выполнить запрос на обновление пароля debian-sys-maint
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘debian-sys-maint’@’localhost’ IDENTIFIED BY ‘Fae4aekeeShiemei6Ohp’;
Обновляем информацию о привилегиях
mysql> FLUSH PRIVILEGES;
Пароль на этом этапе уже обновлен,но для верности можно перезапустить MySQL.
/etc/init.d/mysql restart
После произведенных действий пароль обновился и ошибки больше возникать не должно — в случае с репликацией на всех серверах, которые в ней участвуют для пользователя debian-sys-maint стоит задавать одинаковый пароль.
Home / ERROR 1045 (28000): Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)
If you’ve moved a MySQL installation from one Debian server to another and/or replaced the user logins on your system, you might get the error message «ERROR 1045 (28000): Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)» when attempting to restart MySQL.
Solution
Debian based systems create a user in MySQL called «debian-sys-maint» with a random password. The file the password is stored in as at /etc/mysql/debian.cnf and will look something like this:
# Automatically generated for Debian scripts. DO NOT TOUCH! [client] host = localhost user = debian-sys-maint password = drlkgijhdrouiglr socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = drlkgijhdrouiglr socket = /var/run/mysqld/mysqld.sock basedir = /usr
The solution is to either reset the password for that MySQL user on the local host to what’s currently in the config file, or to copy the password from the config file on the original host to the one on this host.
Note that when copying the password over from the previous host, make sure it gets copied into both password fields in the config file – there are two with identical passwords.
Note also that the password in this file is not hashed in any way – it’s a plain text password.
Symptoms
While trying to start MySQL service, the following error can be found in /var/log/mariadb/mariadb.log
or /var/log/mysql/error.log
error log:
Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)
FATAL ERROR: Upgrade failed
Cause
MySQL upgrade was started and not completed successfully. Defined password in MySQL database is incorrect.
Resolution
- Login to the server via SSH.
-
Find password for debian-sys-maint user in
/etc/mysql/debian.cnf
:# grep ‘password’ /etc/mysql/debian.cnf
password = PASSWORD
password = PASSWORD -
Stop MySQL:
# service mysql stop
-
Add
option into
skip-grant-tables
in
/etc/mysql/my.cnf
section.
[mysqld]
-
Start MySQL:
# service mysql start
-
Login in MySQL:
# plesk db
MYSQL_LIN: > use mysql
-
Update the password which is defined in
/etc/mysql/debian.cnf
:MYSQL_LIN: > UPDATE mysql.user SET Password = password(‘PASSWORD’) WHERE User = ‘debian-sys-maint’;
-
Remove
skip-grant-tables
option in/etc/mysql/my.cnf
: -
Restart mysql
# service mysql start
I just installed a fresh copy of Ubuntu 10.04.2 LTS on a new machine. I logged into MySQL as root:
david@server1:~$ mysql -u root -p123
I created a new user called repl. I left host blank, so the new user can may have access from any location.
mysql> CREATE USER 'repl' IDENTIFIED BY '123';
Query OK, 0 rows affected (0.00 sec)
I checked the user table to verify the new user repl was properly created.
mysql> select host, user, password from mysql.user;
+-----------+------------------+-------------------------------------------+
| host | user | password |
+-----------+------------------+-------------------------------------------+
| localhost | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| server1 | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| 127.0.0.1 | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| ::1 | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| localhost | | |
| server1 | | |
| localhost | debian-sys-maint | *27F00A6BAAE5070BCEF92DF91805028725C30188 |
| % | repl | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+-----------+------------------+-------------------------------------------+
8 rows in set (0.00 sec)
I then exit, try to login as user repl, but access is denied.
david@server1:~$ mysql -u repl -p123
ERROR 1045 (28000): Access denied for user 'repl'@'localhost' (using password: YES)
david@server1:~$ mysql -urepl -p123
ERROR 1045 (28000): Access denied for user 'repl'@'localhost' (using password: YES)
david@server1:~$
Why is access denied?
asked Mar 28, 2013 at 19:44
1
The reason you could not login as repl@'%'
has to do with MySQL’s user authentication protocol. It does not cover patterns of users as one would believe.
Look at how you tried to logged in
mysql -u repl -p123
Since you did not specify an IP address, mysql assumes host is localhost and tries to connect via the socket file. This is why the error message says Access denied for user 'repl'@'localhost' (using password: YES)
.
One would think repl@'%'
would allow repl@localhost
. According to how MySQL perform user authentication, that will simply never happen. Would doing this help ?
mysql -u repl -p123 -h127.0.0.1
Believe it or not, mysql would attempt repl@localhost
again. Why? The mysql client sees 127.0.0.1
and tries the socket file again.
Try it like this:
mysql -u repl -p123 -h127.0.0.1 --protocol=tcp
This would force the mysql client to user the TCP/IP protocol explicitly. It would then have no choice but to user repl@'%'
.
answered Mar 28, 2013 at 20:40
RolandoMySQLDBARolandoMySQLDBA
177k32 gold badges307 silver badges505 bronze badges
0
You should issue for localhost specific to it.
GRANT USAGE ON *.* TO 'repl'@'localhost' IDENTIFIED BY '123';
And try connecting.
answered Mar 29, 2013 at 5:40
MannojMannoj
1,4992 gold badges14 silver badges34 bronze badges
The problem is these two accounts, added by default.
http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html
+-----------+------------------+-------------------------------------------+
| host | user | password |
+-----------+------------------+-------------------------------------------+
| localhost | | |
| server1 | | |
+-----------+------------------+-------------------------------------------+
A blank user name is a wildcard, so no matter what account you use, it matches this user if MySQL thinks you’re connecting from localhost or your local server name (server1 in this case)… since they have no password, any password you try is wrong. User authentication only tries the first match, so the user you created never gets noticed when your host is localhost (or your server name).
Delete these two from the mysql
.user
table and then FLUSH PRIVILEGES;
.
Or, the mysql_secure_installation script can do this for you, although I tend to prefer doing things manually.
http://dev.mysql.com/doc/refman/5.5/en/mysql-secure-installation.html
answered Mar 30, 2013 at 2:02
Michael — sqlbotMichael — sqlbot
22.2k2 gold badges46 silver badges75 bronze badges
Database may not be configured yet just issue a no-arg call:
mysql <enter>
Server version: xxx
Copyright (c) xxx
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
Mysql [(none)]>
If Mysql must be set a root password, you can use
mysql_secure_installation
answered Apr 18, 2020 at 7:45
Make sure that all fields in the connector are set up with the correct details
host = «localhost»,
user = «CorrectUser»,
passwd = «coRrectPasswd»,
database = «CorreCTDB»
Check for upper and lowercase errors as well — 1045 is not a Syntax error, but has to do with incorrect details in the connector
answered Dec 13, 2019 at 22:59
This could be an issue with corruption of your mysql database. Tables inside mysql database like user table can get corrupt and may cause issued.
Please do a check on those
myisamchk /var/lib/mysql/mysql/ *.MYI
Usually while checking or fixing myisam tables we would like to take mysql down first. If this problem is still not solve please try this out aswell.
If they are corrupt then you can fix them using
myisamchk —silent —force —fast /path/table-name.MYI
Thanks,
Masood
answered Mar 31, 2013 at 17:25
Got a problem with a mysql server installation on Debian. (Not my server so I have no idea what caused this…)
Installing new applications that add a database fail with error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I can log in with the user, I’ve flushed permissions…
Then I can across this question:
https://stackoverflow.com/questions/1709078/how-can-i-restore-the-mysql-root-users-full-privileges
But when I try to stop mysql, it fails with
error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'
asked Nov 17, 2012 at 9:19
Debian use debian-sys-maint account for management (start/stop etc.).
Credentials are stored in /etc/mysql/debian.cnf — check if all are valid.
answered Nov 17, 2012 at 15:56
4
There are many ways of restoring the debian-sys-maint
user. Most easy to do is to reconfigure package mysql-server-5.5
. That if you know the password for the root
user of MySQL, you can try to restore the user and its password in /etc/mysql/debian.cnf
.
sudo dpkg-reconfigure mysql-server-5.5
To restore MySQL:s root
password (or any MySQL-users password) you can use the debian-sys-maint
account. You need to run mysql
to get the password for the debian-sys-maint
account.
sudo mysql --defaults-file=/etc/mysql/debian.cnf
mysql> UPDATE mysql.user SET Password=PASSWORD('secret') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> QUIT;
So, never remove the user debian-sys-maint
, as it is used in Debian to administrate MySQL (shut it down, roll logs, upgrade packages, check existans of root
user in MySQL, set new root
user password etc).
answered Jan 2, 2015 at 5:03
AndersAnders
1671 silver badge8 bronze badges
5