'Mysql2::Client::LONG_PASSWORD (NameError)

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?



Solution 1:[1]

I took the mysql2 to version '0.4.10'

Seemed to do the trick

Solution 2:[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

Solution 3:[3]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jepzen
Solution 2 martincito
Solution 3 Goaul