Mysql2::Client::LONG_PASSWORD (NameError)
Asked Answered
W

3

8

I am trying to upgrade my ruby version from 2.4.5 to 2.4.9 in my rails app in Docker.

After rebuilding my container it stops with the error:

uninitialized constant Mysql2::Client::LONG_PASSWORD (NameError)

My version of mysql2 gem is locked on:

gem 'mysql2', '0.3.21'

I tried upgrading the mysql2 gem to version 0.4.0 that just ended up with another error.

Any suggestions on which order to upgrade things to make it work?

Wallah answered 21/1, 2020 at 11:55 Comment(2)
Did you fix that? I am with the same erro Ruby 2.5.8 Rails 4.1.16 Mysql2 0.3.21Truckage
Yes I posted the answerWallah
W
8

I took the mysql2 to version '0.4.10'

Seemed to do the trick

Wallah answered 21/1, 2020 at 16:40 Comment(0)
H
2

There is some updates on mysql gems than your applications doesnt support Search this file on your gemset

gems/mysql2-0.3.21/lib/mysql2/client.rb

At the line Line 12

:connect_flags => REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION,

Change like this

:connect_flags => REMEMBER_OPTIONS | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION,

run migrations

The best practice is to update your code, but with this changes you can continue working

Husking answered 1/12, 2021 at 1:37 Comment(1)
Although this is a hack, this is literally the only solution that worked for me. If I used any version of mysql2 higher than 0.3.21, then rails would complain that mysql2 gem was not installed even though it was. None of the solutions I've read for that problem work at all. So I reverted to 0.3.21 and did this hack, and everything works.Rahman
I
0

Had the same problem with in docker container:

rails 5.1.7
ruby v2.5.9 
mysql2 0.4.6 (using mysql v5.7.18)

Solution:

Upgraded gem mysql2 to 0.5.3

The interesting thing that on mac with local ruby everything was just working fine.

Ido answered 28/4, 2022 at 10:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.