S
S
Sergey None2020-03-06 23:56:24
MySQL
Sergey None, 2020-03-06 23:56:24

How to fix mysql connection via rake db:setup?

When I try to create a database mysql gives me

[email protected]:~/m123$ rake db:setup
/home/sergey/.rvm/gems/ruby-2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/sergey/.rvm/gems/ruby-2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/static.rb:110: warning: The called method `initialize' is defined here
Access denied for user 'root'@'localhost'
Couldn't create 'm123_development' database. Please check your configuration.
rake aborted!
Mysql2::Error: Access denied for user 'root'@'localhost'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `new'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `mysql2_connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:889:in `new_connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:933:in `checkout_new_connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:912:in `try_to_checkout_new_connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:873:in `acquire_connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:595:in `checkout'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:439:in `connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1121:in `retrieve_connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_handling.rb:238:in `retrieve_connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/connection_handling.rb:206:in `connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/mysql_database_tasks.rb:8:in `connection'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/mysql_database_tasks.rb:16:in `create'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:126:in `create'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:185:in `block in create_current'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:479:in `block (2 levels) in each_current_configuration'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:476:in `each'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:476:in `block in each_current_configuration'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:475:in `each'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:475:in `each_current_configuration'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:184:in `create_current'
/home/sergey/.rvm/gems/ruby-2.7.0/gems/activerecord-6.0.2.1/lib/active_record/railties/databases.rake:39:in `block (2 levels) in <main>'
Tasks: TOP => db:setup => db:schema:load_if_ruby => db:create
(See full trace by running task with --trace)

Please help, because of this garbage I have problems.
Basically, I need to fix this.
Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Karpion, 2020-03-07
@Karpion

You have to watch where the program is trying to create 'm123_development'. Either the required directory does not exist, or such a file has already been created - in short, see what's wrong with it, why it can't be created.

V
Vayladion Gognazdiak, 2020-03-10
@etspring

It is forbidden to connect for the root user from the localhost
Give the rights and you will be happy
PS: in the 6th rails everything is done through rails, not rake

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question