SQLサーバソフトの1つ「MySQL」では、DBとのやり取りの際にパスワード認証機能を持っている。このため、コマンドラインで直接やり取りを行おうとしても、次のようにアクセスが拒否されてしまう(ただし、パスワード自体は自らで設定したはずだ。このTipsでは、この設定後に認証をスキップするための手段を紹介している)。
# mysqladmin version mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user: 'root@localhost' (Using password: NO)' |
上記のようにパスワード認証を設定している場合には、次のようにログインを行う必要がある。
# mysql -u root -p Enter password:xxxxxxxxxx Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 to server version: 3.23.56 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> |
上記の設定はセキュリティ上は好ましいかもしれない。しかし、本悪稼働させる前や、一時的に認証無く直接DBとやり取りしたい場合には、bashなどのコマンドプロンプト上で直接操作することも可能だ。
次のように設定ファイル「/etc/my.cnf」内のclientセクションへ「host=」、「user=」、「password=」行を記述しよう。
# cat /etc/my.cnf [client] host=localhost user=root password=xxxxxxx 〜以下略〜 |
Copyright © ITmedia, Inc. All Rights Reserved.