-3

I get this error:

No connection pool with 'primary' found.
        raise ConnectionNotEstablished, "No connection pool with '#{spec_name}' found for the '#{ActiveRecord::Base.current_role}' role."
          else
            raise ConnectionNotEstablished, "No connection pool with '#{spec_name}' found."
          end
        end

This is my default:

&default
  adapter: ruby-mysql
  encoding: utf8mb4
  pool: 5
  username: root
  password: 
  host: localhost
development:
  <<: *default
  database: demo_project_development
production:
  <<: *default
  database: demo_project_production
  username: root
  password: 
)

MySQL is runnning, the tutorial I was following was using the mysql2 adapter.

My Ruby version is 2.6.5.

Note I have no tables in my database:

activerecord (6.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:1117:in `retrieve_connection'
activerecord (6.0.1) lib/active_record/connection_handling.rb:238:in `retrieve_connection'
activerecord (6.0.1) lib/active_record/connection_handling.rb:206:in `connection'
activerecord (6.0.1) lib/active_record/migration.rb:562:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.1) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (6.0.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.1) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.1) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
actionpack (6.0.1) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
webpacker (4.2.0) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.1) lib/rails/engine.rb:526:in `call'
puma (4.3.0) lib/puma/configuration.rb:228:in `call'
puma (4.3.0) lib/puma/server.rb:667:in `handle_request'
puma (4.3.0) lib/puma/server.rb:470:in `process_client'
puma (4.3.0) lib/puma/server.rb:328:in `block in run'
puma (4.3.0) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
6
  • 1
    Where and how do you get that error? It's not a stack trace. Show an actual error in the form of a stack trace. MRE please. Commented Nov 23, 2019 at 1:11
  • 1
    Don't say "getting an error" in the title, please try and focus on what the problem is, explain better what the error is. Commented Nov 23, 2019 at 1:16
  • @ cannot load such file -- mysql2/2.6/mysql2 Commented Nov 23, 2019 at 3:34
  • minimal reproducible example minimal reproducible example minimal reproducible example! How do you generate this error, what are your steps to reproduce, what is the full example to allow this to be reproduced? Commented Nov 23, 2019 at 4:05
  • running rails s command Commented Nov 23, 2019 at 4:05

1 Answer 1

1

Don't use the ruby-mysql gem. Just by looking at the github repo you can see that the last commit was four years ago and almost all the commits are from a single author, additionally the readme is in Japanese. That does not bode well.

Instead use the mysql2 gem which is actively maintained. You can generate a Rails application already set up for MySQL by running:

rails new my_app --database=mysql

Or, if you want to fix your existing application, replace ruby-mysql with mysql2 in your Gemfile and set the correct adapter:

default: &default
  adapter: mysql2
  # ...
Sign up to request clarification or add additional context in comments.

9 Comments

I did Now I need to install my sql2 so I get Error installing mysql2: mysql2 requires Ruby version < 2.6, >= 2.0.
Yeah, but why do you have a ruby version older than 2.0 in the first place? Thats really old
I have 2.6.5 @Max
What version of the mysql2 gem are you trying to install? 0.5.2 just lists the version as s.required_ruby_version = '>= 2.0.0'. You should be using something like gem 'mysql2', '~> 0.5.2'. github.com/brianmario/mysql2/blob/…
so any soultion ?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.