rails db:migrate rails aborted! Mysql2::Error: Access denied for user 'root'@'localhost' (using password: YES)

sadeq alshaar

I'm running this migration:

class CreateAdmins < ActiveRecord::Migration[5.1]
  def change
    create_table :admins do |t|

      t.string "first_name" :limit => 30
      t.string "last name", :limit => 30
      t.string "email", :default => '', :null => false
      t.string "password" ,:limit => 40
      t.timestamps

    end
  end

  def down
    drop_table :admins
  end
end

I get an error saying:

rails db:migrate rails aborted! Mysql2::Error: Access denied for user 'root'@'localhost' (using password: YES)

Michael Arkhipov

For the first, this is correct migration code:

class CreateAdmins < ActiveRecord::Migration[5.1]
  def self.up
    create_table :admins do |t|
      t.string :first_name, limit: 30
      t.string :last_name, limit: 30
      t.string :email, default: '', null: false
      t.string :password ,limit: 40

      t.timestamps
    end
  end

  def self.down
    drop_table :admins
  end
end

or just change difference

class CreateAdmins < ActiveRecord::Migration[5.1]
  def change
    create_table :admins do |t|
      t.string :first_name, limit: 30
      t.string :last_name, limit: 30
      t.string :email, default: '', null: false
      t.string :password ,limit: 40

      t.timestamps
    end
  end
end

About error, your database.yml for development env, should looks like this:

development:
  adapter: mysql2
  encoding: utf8
  database: your_db_name
  username: your_user
  password: your_password
  host: 127.0.0.1
  port: 3306

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Ruby on rails - Mysql2::Error Access denied for user 'simple_cms'@'localhost' (using password: YES)

From Dev

Locall MySQL DB login Error : Access denied for user 'root'@'localhost' (using password: YES)

From Dev

error: 'Access denied for user 'root'@'localhost' (using password: YES)'

From Dev

Brew mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Rails database issue - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

From Dev

Access denied for user 'root'@'localhost' (using password: YES)

From Java

Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges?

From Dev

OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

From Dev

OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

From Java

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Php Post Insert Error Access denied for user 'root'@'localhost' (using password: YES)

From Dev

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

From Dev

lavaral 5 ERROR{ (SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)}

From Dev

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) after set plugin = ''

From Dev

MySQL Access denied for user 'User'@'localhost' (using password: YES)

From Dev

ajax with jsp and mysql : java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES)

From Dev

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

From Dev

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

From Java

MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

From Dev

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

From Dev

Access denied for user 'root'@'localhost' (using password: Yes) after password reset LINUX

From Dev

Unable to access MySQL from C# application because of Exception: "Access denied for user 'root'@'localhost' (using password: YES)"

From Dev

Access denied for user 'root'@'localhost' (using password: NO);

From Dev

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

From Dev

PyCharm - Database connection. Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Laravel Access denied for user 'root'@'localhost' (using password: YES) in laravel 4.2

From Dev

c3p0 access denied for user 'root'@'localhost' (using password yes)

From Dev

Access denied for user 'root'@'%' (using password: YES) but logged in as root

Related Related

  1. 1

    Ruby on rails - Mysql2::Error Access denied for user 'simple_cms'@'localhost' (using password: YES)

  2. 2

    Locall MySQL DB login Error : Access denied for user 'root'@'localhost' (using password: YES)

  3. 3

    error: 'Access denied for user 'root'@'localhost' (using password: YES)'

  4. 4

    Brew mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

  5. 5

    Rails database issue - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

  6. 6

    Access denied for user 'root'@'localhost' (using password: YES)

  7. 7

    Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges?

  8. 8

    OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

  9. 9

    OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

  10. 10

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

  11. 11

    Php Post Insert Error Access denied for user 'root'@'localhost' (using password: YES)

  12. 12

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

  13. 13

    lavaral 5 ERROR{ (SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)}

  14. 14

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) after set plugin = ''

  15. 15

    MySQL Access denied for user 'User'@'localhost' (using password: YES)

  16. 16

    ajax with jsp and mysql : java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

  17. 17

    Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES)

  18. 18

    SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

  19. 19

    SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

  20. 20

    MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

  21. 21

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

  22. 22

    Access denied for user 'root'@'localhost' (using password: Yes) after password reset LINUX

  23. 23

    Unable to access MySQL from C# application because of Exception: "Access denied for user 'root'@'localhost' (using password: YES)"

  24. 24

    Access denied for user 'root'@'localhost' (using password: NO);

  25. 25

    java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

  26. 26

    PyCharm - Database connection. Access denied for user 'root'@'localhost' (using password: YES)

  27. 27

    Laravel Access denied for user 'root'@'localhost' (using password: YES) in laravel 4.2

  28. 28

    c3p0 access denied for user 'root'@'localhost' (using password yes)

  29. 29

    Access denied for user 'root'@'%' (using password: YES) but logged in as root

HotTag

Archive