, ,

Recently, I have encountered an error in my rails app when I tried to execute the rake commands like rake routes, rake assets:precompile RAILS_ENV=production in my railsprod.ctu.com(production server). The error says: rake aborted. Access denied for user ‘root’@beta07.ctu.com’ Using password:YES. The problem was railsprod.ctu.com cannot directly access to the external db server(beta07-db.ctu.com).
To fix the problem, you need to grant the root access to beta07.ctu.com server. See the mysql command below:

mysql> grant ALL on *.* to 'root'@'beta07.ctu.com' identified by 'currentmysqlpasswordd';
Query OK, 0 rows affected (0.04 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)

# Check if the hostname is added by executing select query below
mysql> select user,host from mysql.user;
2 rows in set (0.00 sec)

Thats all..