MySQLでデータベースに接続する際、エラーERROR 2049が発生する場合があります。
これは、クライアント側のmysqlコマンドでsecure_authオプションが有効になっているときに発生します。
このような場合にとりあえず接続したいときは、–skip-secure-authオプションをつければOKです。
普通に接続すると、ERROR 2049エラーが出ます。
$ mysql -u root -h localhost -p Enter password: ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled) |
mysqlコマンドに、–skip-secure-authオプションをつけたら接続可能になりました。
※ –secure-auth=0でもOKです。
$ mysql -u root -h localhost -p --skip-secure-auth Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 76561232 Server version: 5.1.72-community-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> |
基礎からのMySQL
–skip-secure-authオプションの意味は下記のとおりです。
ちなみに、MySQLの5.7.5以降のバージョンでは–skip-secure-authは非推奨となっており、将来のバージョンでなくなる予定です。
--secure-auth Do not send passwords to the server in old (pre-4.1) format. This prevents connections except for servers that use the newer password format. As of MySQL 5.7.5, this option is deprecated and will be removed in a future MySQL release. It is always enabled and attempting to disable it (--skip-secure-auth, --secure-auth=0) produces an error. Before MySQL 5.7.5, this option is enabled by default but can be disabled. Note Passwords that use the pre-4.1 hashing method are less secure than passwords that use the native password hashing method and should be avoided. Pre-4.1 passwords are deprecated and support for them is removed in MySQL 5.7.5. For account upgrade instructions, see Section 7.5.1.3, “Migrating Away from Pre-4.1 Password Hashing and the mysql_old_password Plugin”. |
また、my.cnfの編集が可能な場合は、my.cnfへ下記の設定を追加してもOKです。
[mysqld] skip-secure-auth |
このエラーが出る理由は、古い形式のパスワードハッシュを使用しているためです。
セキュリティ上は好ましくないため、本来ならパスワード形式を変更しておくべきです。
MySQL 5.7以降で、あえて古い形式のパスワード管理をする必要がある場合は、下記のページの内容(mysql_old_passwordプラグイン)が参考になります。
http://dev.mysql.com/doc/refman/5.7/en/account-upgrades.html
参考:
Skip Secure Auth – MySQL 5.6.15
http://serverfault.com/questions/573809/skip-secure-auth-mysql-5-6-15/617108
MySQL 5.6で、コマンドラインに「–skip-secure-auth」を追加?
http://programmer-jobs.blogspot.jp/2014/06/mysql-community-server-5-6-skip-secure-auth.html
MySQL 5.7.5でsecure-authが軒並み使えなくなるはなし
https://yoku0825.blogspot.jp/2014/10/mysql-575secure-auth.html
<続>MySQL 5.6 old_passwords=1 環境へのユーザー情報移行が難しい
ttp://moontalk.hatenablog.com/entry/2013/12/16/221508
実践ハイパフォーマンスMySQL
関連記事
コメントを残す