Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "Access denied for user 'root'@'localhost' (using password: NO)" in production mode and no errors getting logged

I deployed my Rails app and am getting 500 Errors on all pages. My production.log isn't showing anything (which is a problem), but I did a 'script/console production' and tried to run a simple query (User.find :first) and it throws this:

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

My database.yml file definitely has a password there and it's correct.

So, that plus no errors being logged to my production.log file is making me wonder what's up.

Any ideas where I'd start looking or what the issue could be?

Also, for what it's worth, I'm running Passenger on Apache.

UPDATE: Here's my database.yml file contents

development:
  adapter: mysql
  encoding: utf8
  database: website_development
  username: root
  password: secretz
  socket: /tmp/mysql.sock

test:
  adapter: mysql
  encoding: utf8
  database: website_test
  username: root
  password: secretz
  socket: /tmp/mysql.sock

production:
  adapter: mysql
  encoding: utf8
  database: website_production
  username: ttp_mysql
  password: secretz
  socket: /var/run/mysqld/mysqld.sock

NEW UPDATE: I changed the mysql user so it wasn't running in root, but now I'm still getting the "Access denied for 'root'@'localhost'" bit...even though in production mode it shouldn't be running as 'root' at all.

Really really confused now.

like image 260
Shpigford Avatar asked Dec 18 '22 04:12

Shpigford


1 Answers

So I found the issue. I had added some files to my /models folder for doing some database migrations from an old database.

In those files I had "ActiveRecord::Base.establish_connection" to connect to the database and somehow those were overriding what was in my database.yml file (even though I wasn't calling those files directly).

Either way...removing those solved the issue.

Thanks for taking the time to try to figure this out!

like image 103
Shpigford Avatar answered Dec 19 '22 19:12

Shpigford