LoginSignup
9

More than 5 years have passed since last update.

昔っぽいMySQLにmysql2とかからつなぎにいくと怒られる件の対処

Last updated at Posted at 2013-12-05
Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled) 

って言われる。これはRubyやActiveRecordがどうこうと言うかlibmysqlの問題の模様。

手元のMySQLのバージョンが5.6とかだと、それに添付されるソースでコンパイルしたgemはメッセージ通り secure_auth が有効になっているので古いMySQLのサーバにつなぎに行けないようだ。解決策としては、手元のMySQLも古くして再コンパイルするのが手っ取り早いようだ。

brew tap homebrew/versions
brew install homebrew/versions/mysql51
brew link --force mysql51

なお、12月現在mysql51.rbフォーミュラはインストールできない状態なので以下のようにするしか無い(TODO:プルリする)

diff --git a/mysql51.rb b/mysql51.rb
index 4604b27..1e12954 100644
--- a/mysql51.rb
+++ b/mysql51.rb
@@ -2,8 +2,8 @@ require 'formula'

 class Mysql51 < Formula
   homepage 'http://dev.mysql.com/doc/refman/5.1/en/'
-  url 'http://mysql.mirrors.pair.com/Downloads/MySQL-5.1/mysql-5.1.71.tar.gz'
-  sha1 'a71c77c43aa8374ccb6e09f0ad7f225846af59e6'
+  url 'http://mysql.mirrors.pair.com/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz'
+  sha1 '6cb1c547dec873a0afda825c83fd8e5a32b9a619'

   option :universal
   option 'with-tests', 'Keep tests when installing'

あとはgemを再度インストールするとかbundle installを消してやり直すとかする感じ。

ここからあとで試す

MySQL5.6でも、この記事にある感じのパッチ(mysql->options.secure_auth= FALSE; にする)を手元にあるはずのソースに突っ込んで、gemを再コンパイルすれば大丈夫になるかも?

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9