1

I want run a rake db:migrate, but migrated are aborted and i see this error:

rake aborted!
Mysql2::Error: Access denied for user 'root'@'localhost' (using password: YES)
/home/marketa/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.20/lib/mysql2/client.rb:70:in `connect'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.20/lib/mysql2/client.rb:70:in `initialize'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:87:in `connection'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:913:in `initialize'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `new'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `up'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:798:in `migrate'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/home/marketa/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/home/marketa/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/home/marketa/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

if I run a server I will see this error page:

Mysql2::Error
Access denied for user 'root'@'localhost' (using password: YES)
Extracted source (around line #70):       


     socket = socket.to_s unless socket.nil?

      connect user, pass, host, port, database, socket, flags #70line is this
    end

    def self.default_query_options

my database.yml file looks like this:

default: &default
  adapter: mysql2
  pool: 5
  timeout: 5000
  host: localhost
  username: root
  password: hazzy93

development:
  <<: *default
  database: db/dev.mysql2

test:
  <<: *default
  database: db/test.mysql2

production:
  <<: *default
  database: db/production.mysql2
2
  • are you able to connect to this db from coming line or some other tool using those credentials? Commented Nov 4, 2015 at 14:10
  • update your database. 'database: "dev"' and not 'database: db/dev.mysql2' Commented Nov 4, 2015 at 14:15

2 Answers 2

0

Try this

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: development
  pool: 5
  username: root
  password: hazzy93
  host: localhost


test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: test
  pool: 5
  username: root
  password: hazzy93
  host: localhost

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: production
  pool: 5
  username: root
  password: hazzy93
  host: localhost
Sign up to request clarification or add additional context in comments.

2 Comments

still not working :/
You sure your username and password is correct?
0

You need to correct your database.yml It should look like this:

default: &default
  adapter: mysql2
  host: 127.0.0.1
  port: 3306
  username: root
  password: hazzy93

development:
  <<: *default
  database: development

test:
  <<: *default
  database: test

production:
  <<: *default
  database: production

You used the Syntax for sqlite3

2 Comments

not working :/ i have got still the same error
is your username and your password defently correct?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.