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

來源:互聯網
上載者:User

系統版本資訊:
# mysql -V
mysql  Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (i486) using readline 5.2
# uname -a
Linux auto-at-server 2.6.18-6-686 #1 SMP Tue Jun 17 21:31:27 UTC 2008 i686 GNU/Linux

重啟Mysql報錯如下:
# /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)'

Google了一下:"debian-sys-maint" 使用者是用來啟動和停止資料庫以及其它一些維護資料庫操作使用的(Linux作業系統)。
這玩意的密碼怎麼會改變那,查了半天解釋如下:
Linux作業系統下啟動Mysql時,mysql會在檔案中 /etc/mysql/debian.cnf
查詢 debian-sys-maint 使用者的密碼資訊。

而這個檔案中的密碼資訊是由Mysql即時同步進去的,問題應該就出在這,之前mysql異常退出了,導致資訊沒有同步。

在加上之前我確實對root使用者的密碼資訊進行修改了,可能誤操作把這玩意也改了。

解決如下:
1:查詢debian-sys-maint使用者的密碼資訊
# cat /etc/mysql/debian.cnf

# 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

2:登入mysql修改密碼
# mysql -u root -p<password>

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

3:重啟成功
# /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.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.