All threads / Mysql2::Error::ConnectionError: Access denied for user 'root'@'localhost' (using password: NO)

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Mysql2::Error::ConnectionError: Access denied for user 'root'@'localhost' (using password: NO)

Migue9936 asked in Databases

Hello, I have problems with my connection to mysql and rails, when I access mysql through the terminal with the root user I have no problem, but when I do a db: create rails but I get the error that is in the title.

If you are using Homebrew and Mac for the MySQL installation, try this : https://stackoverflow.com/a/44147346

Try this on your database.yml:

default: &default
adapter: mysql2
username: root
password:
socket: /tmp/mysql.sock

Mysql usually come with auth_socket as default authentication plugin, if you want to use authentication by password, you must change the user's authentication plugin to caching_sha2_password.

You can try to run this on MySQL terminal:

mysql> CREATE USER ‘username’@‘localhost’ IDENTIFIED BY ‘password’;
mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
mysql> FLUSH PRIVILEGES;

Then you should be good to go.

Thank u so much for taking time to help.

I have some issue - best place to ask? https://get-mxplayer.in

Thanks for your help guys

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,106+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.