1

I have looked through a lot of similar solutions but have been unable to resolve my issue so hopefully someone can help.

I have joined a Rails project and need to pull data via a dump.sh file to enable me to work locally. Whenever I run the required command, I receive this error:

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

If I try mysql -u root I see the exact same error message.

Trying mysql -u root -p requires my password to be entered (it is the same password in the database.yml file) which is kind of weird - surely this step should not work based on my error message?

My database.yml file looks like this for development:

development: adapter: mysql2 database: database_development host: localhost port: 3306 username: root password: "password_is_here" pool: 5 timeout: 5000

I feel like I am missing something really basic here, but cannot for the life of me work out what it is :-/

EDIT: Forgot to mention, the database exists and has been migrated so rake db:create and rake db:migrate are not the issues.

EDIT2: My test database has the same information

kuwantum
  • 314
  • 2
  • 4
  • 14
  • Try this answer on stack overflow [ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)](https://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y) to configure mysql correctly on linux – Kaviranga Aug 17 '17 at 03:06
  • Unfortunately I don't see anything there that I haven't already tried (including setting new passwords, restarting the SQL server etc). I still continue to receive the "using password: NO" message. – kuwantum Aug 17 '17 at 03:11
  • How about your **dump.sh** script looks like ?. It will be helpful to answer the question if you posted the codes of dump.sh with your question.Have you added mysql privileges to it?. – Kaviranga Aug 17 '17 at 03:17
  • It's something I cannot (contractually) post I am afraid - it definitely works though as others in my team have run it without issues. – kuwantum Aug 17 '17 at 03:18
  • Ok you have two solutions . You can change the permissions of ***dump.sh*** using **chmod** or **chown** commands to work locally on your computer. Or you can add the these changes to ***database.yml*** file as , add `default: &default adapter: mysql2 encoding: utf8 pool: 5 username: root password: host: localhost development: <<: *default database: database_development` – Kaviranga Aug 17 '17 at 03:25
  • Have you tried flushing privileges and granting privileges to `rails_user` on both your test and production database? – the12 Aug 17 '17 at 03:37

1 Answers1

3

I have seen this error before, that was because the database.yml contain some special characters that can't see in normal mode of text editor. I suggest to try to create totally new database.yml file from scratch then input database info again manually, restart the server to check the result.

Tai
  • 1,244
  • 9
  • 11
  • Must have been something connected to that as you mentioned. Re-wrote it from scratch and it works perfectly now so thank you! – kuwantum Aug 17 '17 at 04:09