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

I deployed a Rails application and get 500 errors on all pages. My production.log does not show anything (which is the problem), but I did a "script / console production" and tried to run a simple request (User.find: first), and it produces the following:

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

My database.yml file definitely has a password and it is correct.

So, this plus the lack of errors logged in my production.log file makes me wonder what happened.

Any ideas where I will start looking or what might be the problem?

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

UPDATE: here is the contents of the database database.yml

 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 didnโ€™t work in the root, but now I still get the "Access denied for" root @localhost bit .. although in production mode it should not work as the "root" at all.

Really really confused.

+4
source share
4 answers

So, I have found a problem. I added some files to my / models folder to perform some database migrations from the old database.

In these files, I had "ActiveRecord :: Base.establish_connection" to connect to the database, and for some reason it was an override of what was in my database.yml file (even if I did not call these files directly).

In any case ... removing these problems.

Thanks for taking the time to try and figure it out!

+5
source

The fact that he is trying to use the root account in conjunction with the fact that you do not see anything in his production.log file seems to indicate that the application does not work in production .

To check if this is true or not, try adding the following line to the environment.rb file (above), restart the application and see if you still get the same error:

 ENV["RAILS_ENV"] = "production" 

Note For obvious reasons, this is a good not good practice, so even if it works, I suggest finding out the reason and removing this line from the file. However, seeing that you see problems on your production server, I hope this answer at least makes you (back) work while you continue to diagnose why it did not work in production mode in the first place.

+4
source

I had the same problem and realized that I did not restart the rails server. Give it a try.

+2
source

I had the same problem. I closed all terminals and restarted the server. It works great!

+1
source

All Articles