kuwantum kuwantum - 1 year ago 105
MySQL Question

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

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download