1

I was following the instructions in this post:

https://blog.openshift.com/sharing-database-across-applications/

And I have two apps running successfully, with data in my production app, with my reports app up trying to query the production database. From my production app, I am able to grab the HOST, PORT, USERNAME, AND PASSWORD.enter image description here

On my reports app, I have a simple test script to test connectivity:

$db = mysql_connect('127.7.171.129:3306', 'USER','PW');

if (!$db) {
  echo "Could not connect to database: " . mysql_error();
} else {
  echo "Connected to database.<br>";
}

The error I am getting is:

Could not connect to database: Lost connection to MySQL server at 'reading initial communication packet', system error: 113

Any help would be appreciated.

etm124
  • 2,100
  • 4
  • 41
  • 77

1 Answers1

1

You need to have created your production application as a scaled application so that you can access it's database from your other applications (as the database will then be on it's own gear). Since your database connection is using port 3306, it is probably not a scaled application, as the port number would be something different, and the host would be a FQDN instead of an ip address.

  • Is there anything I can do in my scenario? Currently the main application is a ruby app with the production database. My reporting app is a separate php app trying to connect. Another thought is to just write ruby code within the app as a reporting module. – etm124 Jul 30 '15 at 16:37
  • The correct way to do it is to write an API within your ruby application that the php application connects to for it's data. –  Jul 30 '15 at 19:02