WEBの勉強ノート
Loading

MySQLで「mysqladmin: connect to server at ‘localhost’ failed error: ‘Access denied for user ‘root’@'localhost’ (using password: NO)’」

2010 年 1 月 1 日 カテゴリー: MySQL

インストール後、初期設定や動作確認で以下のメッセージが発生する場合がある。たとえば、mysqladmin version などの実行の際。

[root@localhost bin]# mysqladmin version
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)' 

これは、MySQL の root ユーザーにパスワードを設定した場合に発生する。mysqladmin -u root password ‘new-password’ の実行など。mysqladmin の実行時には、ユーザー名 root を付加し、パスワードを入力することで実効することができる。

[root@localhost bin]# mysqladmin version -u root -p
Enter password:
mysqladmin  Ver 8.42 Distrib 5.1.42, for pc-linux-gnu on i686
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license


Server version          5.1.42-community
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 11 min 31 sec
Threads: 1  Questions: 6  Slow queries: 0  Opens: 15  Flush tables: 1  Open tables: 8  Queries per second avg: 0.8

コメントをどうぞ