0
votes

Trying to connect to a dababase which is in a different server:

Command line

php symfony configure:database "mysql:host=<IP>;dbname=<db_name>" <username> <password>  

Databases.yml

  all:   
    doctrine:     
    class: sfDoctrineDatabase     
      param:       
      dsn: 'mysql:host=<IP>;dbname=<db_name>'
      username: <username>       
      password: <password>  

Getting error:

PDO Connection Error: SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

2
Have you tried, from command line, to connect to that server? To me it sounds more like a problem on the sql server side. - Vlad Jula-Nedelcu
Yes, tried from command line.. Tried connecting to two different server, same error.. Is there any config that needs to be changed in the server to allow remote access ? - TomCat

2 Answers

0
votes

You need to grant access to the user from that host. Something like

GRANT ALL ON mydb.* TO 'someuser'@'somehost';

More here.

0
votes
Apologies for making this a bit long. 
This is the server my.cnf                                                           

[mysqld]
# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under different user or group, 
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
user=mysql

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
;plugin-load=rpl_semi_sync_master=semisync_master.so
# uncomment next line on SLAVE
;plugin-load=rpl_semi_sync_slave=semisync_slave.so

# Others options for Semisynchronous Replication
;rpl_semi_sync_master_enabled=1
;rpl_semi_sync_master_timeout=10
;rpl_semi_sync_slave_enabled=1

# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
;performance_schema


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid