0

guys. I know that post not fully related to programming. But I really need someone help. So my problem is:

I have Symfony2 application, I move it from localhost to development server with, but I cant run application because I geeting error:

 Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'xx.xx.xxx.xxx' (4)' in /var/www/route/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 40

I trying to find solution in Stackoverflow and in internet, I found that mysql has config file which blocking external resources and accept only 127.0.0.1 address, so I commented both lines as described here.

My Symfony2 database parameters looks like:

parameters:
  database_driver: pdo_mysql
  database_host: localhost
  database_port: null
  database_name: db_name
  database_user: user
  database_password: pass

Can someone help to me? Thanks!

Community
  • 1
  • 1
nowiko
  • 2,507
  • 6
  • 38
  • 82
  • database_port: null, why is it normal?, I do not know about Symfony2 but the mysql port normal is 3306, for the other parameters you know best check that you can connect with the MySQLWorkbench – Petter Friberg Nov 19 '15 at 19:46
  • @PetterFriberg, using mysqli php extension I can connect to database and all works fine, I really cant get why this doent work with pdo – nowiko Nov 19 '15 at 20:01

2 Answers2

3

Check logs in app/logs/dev.log and/or you server logs.

Are you sure that hostname an user/password combination are correct?

Where is your database? If I understood it correctly, you have your own VPS? If so, how you've configured it?

Probably it's not a serious issue, but we need more data.

Mateusz Sip
  • 1,280
  • 1
  • 11
  • 11
0

+1 @Mateusz Sip

You probably have a specific configuration or simply not have properly installed and configured mysql on your server.

Also you should try to do mysql -u yourusername -p If it ask for your password , mysql is installed. Enter your password and let know us if you are correctly logged in.

chalasr
  • 12,971
  • 4
  • 40
  • 82