Недавно я обновил mysql с помощью обновления кипения до самой новой версии:
$ mysql -V
mysql Ver 8.0.11 for osx10.13 on x86_64 (Homebrew)
Теперь мое соединение Ruby on Rails mysql перестало работать.
Для совместимости с производственной средой я должен использовать gem 'mysql', '2.8.1'
и перед обновлением все отлично работало. После обновления mysql появляется следующее сообщение об ошибке:
$ rails s
=> Booting WEBrick
=> Rails 3.2.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.
Called from: /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/actionpack-3.2.5/lib/action_dispatch/middleware/session/abstract_store.rb:28:in 'initialize'.
Exiting
/Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/mysql_adapter.rb:32:in 'mysql_connection': undefined method 'init' for Mysql:Class (NoMethodError)
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in 'send'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in 'new_connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in 'checkout_new_connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:241:in 'checkout'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in 'loop'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in 'checkout'
from /Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/monitor.rb:242:in 'synchronize'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:233:in 'checkout'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in 'connection'
from /Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/monitor.rb:242:in 'synchronize'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in 'connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in 'retrieve_connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in 'retrieve_connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in 'connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/model_schema.rb:308:in 'clear_cache!'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/railtie.rb:97:in '_callback_before_13'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:418:in '_run__1580337521__prepare__4__callbacks'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:405:in 'send'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:405:in '__run_callback'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:385:in '_run_prepare_callbacks'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:81:in 'send'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:81:in 'run_callbacks'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/actionpack-3.2.5/lib/action_dispatch/middleware/reloader.rb:74:in 'prepare!'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/actionpack-3.2.5/lib/action_dispatch/middleware/reloader.rb:48:in 'prepare!'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/application/finisher.rb:47
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:30:in 'instance_exec'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:30:in 'run'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:55:in 'run_initializers'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:54:in 'each'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:54:in 'run_initializers'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/application.rb:136:in 'initialize!'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/railtie/configurable.rb:30:in 'send'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/railtie/configurable.rb:30:in 'method_missing'
from /Users/MyAccount/Development/REPRO/webapp/config/environment.rb:9
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in 'gem_original_require'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in 'require'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in 'require'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:236:in 'load_dependency'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in 'require'
from /Users/MyAccount/Development/REPRO/webapp/config.ru:3
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/rack-1.4.7/lib/rack/builder.rb:51:in 'instance_eval'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/rack-1.4.7/lib/rack/builder.rb:51:in 'initialize'
from /Users/MyAccount/Development/REPRO/webapp/config.ru:0:in 'new'
from /Users/MyAccount/Development/REPRO/webapp/config.ru:0
Как я могу решить эту проблему? Есть ли способ решить соединение mysql?
К сожалению, mysql2
не является вариантом для производственной среды.
Обновление версий mysql:
$ brew info mysql
mysql: stable 8.0.11 (bottled)
Open source relational database management system
https://dev.mysql.com/doc/refman/8.0/en/
Conflicts with:
mariadb (because mysql, mariadb, and percona install the same binaries.)
mariadb-connector-c (because both install plugins)
mysql-cluster (because mysql, mariadb, and percona install the same binaries.)
mysql-connector-c (because both install MySQL client libraries)
percona-server (because mysql, mariadb, and percona install the same binaries.)
/usr/local/Cellar/mysql/5.7.21 (323 files, 233.9MB)
Poured from bottle on 2018-02-21 at 14:26:22
/usr/local/Cellar/mysql/8.0.11 (254 files, 232.6MB) *
Poured from bottle on 2018-06-22 at 06:21:48
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb
==> Dependencies
Build: cmake
Required: openssl
==> Requirements
Required: macOS >= 10.10
==> Options
--with-debug
Build with debug support
--with-embedded
Build the embedded server
--with-local-infile
Build with local infile loading support
--with-memcached
Build with InnoDB Memcached plugin
--with-test
Build with unit tests
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
С 5.7.21 все работало.
После много работы я смог найти преступника. MySQL 8.0.11 недостаточно стабилен и разбивает несколько моих драгоценных камней.
В итоге этого было достаточно:
$ brew info mysql
(чтобы получить информацию об установленных версиях)
$ brew switch mysql 5.7.21
(для перехода на стабильную версию)
Теперь сервер, mysql gems, а также соединения DB снова работают...
Не было необходимости удалять mysql 8 в моем случае.