How to use mysql2 0.3.16 with Ruby 1.9.3? (uninitialized constant Mysql2::Client::SECURE_CONNECTION)

1k Views Asked by At

I'm trying to set up my local dev environment to match my team's. I can't upgrade Ruby/Rails/mysql2 (for the time being).

I know my local MySQL config is good (enough?) because I can create a new Rails project and run it just fine. I'm getting the same error if I run rake db:create or rails s or even start IRB and run require 'mysql2'.

I've googled the hell out of this. I was initially using MariaDB as my MySQL implementation locally, so I thought that might be screwing with the mysql2 gem. So I ripped out MariaDB and finally got MySQL 5.6 working (another team version we're locked into at the moment). After successfully upgrading to MySQL 5.6, I'm confident that's 100% not the issue.

I would expect if I had the wrong password for it to complain about the config somehow, but it's always the same.

uninitialized constant Mysql2::Client::SECURE_CONNECTION  

Ruby (RVM): ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
Mysql2: 0.3.16

There have been some other version-related struggles, but nothing this strong. The only thing I've encountered that I haven't actually tried is building the mysql2 gem locally.

I would expect require 'mysql2' to at least load the gem. Neither Rails nor Rake will work with the gem at all. It's almost like it's missing some internal file.

1

There are 1 best solutions below

1
Khanh Pham On

following as discussion about this error in official gem, you should update version as

From

gem 'mysql2', '0.3.16'

to

gem 'mysql2', '0.3.17'

if you still met an error after you update version to 0.3.17, i think that you should update to 0.2.24

https://github.com/brianmario/mysql2/issues/603