This topic is locked
[SOLVED]

 Fatal error: Unknown MySQL server host

6/11/2020 2:30:08 AM
PHPRunner General questions
S
seedavidwork author

I am trying to move from a local version of MySQL to an Azure Database for MySQL sever. I can connected to the database from my local machine using PHPRunner app and from Heidi SQL browser , but when I upload the application to both my local dev web server or a LAMP vm I created in Azure I get the following errors.
From my Azure Webserver "Fatal error: Connection timed out"
From my local development server connecting to the Azure DB
( ! ) Fatal error: Unknown MySQL server host 'mydatabasename.database.azure.com' (111) in /var/www/dev4/connections/Connection.php on line 626

Call Stack

Time Memory Function Location

1 0.0012 233568 {main}( ) ../login.php:0

2 0.0019 236104 require_once( '/var/www/dev4/include/dbcommon.php' ) ../login.php:5

3 0.0253 273648 include( '/var/www/dev4/include/appsettings.php' ) ../dbcommon.php:94

4 0.0650 1235096 ConnectionManager_Base->getDefault( ) ../appsettings.php:744

5 0.0650 1235224 ConnectionManager_Base->byId( ) ../ConnectionManager_base.php:115

6 0.0650 1235448 ConnectionManager->getConnection( ) ../ConnectionManager_base.php:95

7 0.0665 1285920 MySQLiConnection->construct( ) ../ConnectionManager.php:22

8 0.0665 1286024 Connection->
construct( ) ../MySQLiConnection.php:22

9 0.0671 1308400 MySQLiConnection->connect( ) ../Connection.php:54

10 0.0679 1309144 Connection->triggerError( ) ../MySQLiConnection.php:101

11 0.0679 1309272 trigger_error ( ) ../Connection.php:626

S
seedavidwork author 6/11/2020



https://xlinesoft.com/blog/2016/01/05/running-asprunner-net-and-phprunner-apps-on-microsof-azure/


I read this article and it doesn't address my specific problem of connecting to the database. As I mentioned in my post, I can see and edit the Azure database from the Windows computer running PHPRunner and also from a 3rd party app called Heidi SQL. When I post the project to a web server on the same IP that I can connect to the DB with PHPRunner, I get the connection error I posted from PHP.

Admin 6/11/2020

mydatabasename.database.azure.com doesn't look right. Is this the actual MySQL server address?

S
seedavidwork author 6/11/2020



mydatabasename.database.azure.com doesn't look right. Is this the actual MySQL server address?


This is not the actual db name. I just changed the actual name to hide it in this post. I can login to the Azure MySQL DB from the CLI of the Azure Web Host VM using the command 'mysql -h HOSTNAME -u USERNAME -p' (with the same info I have put into my PHPRunner app) but when I launch the PHRRunner APP from the same web server I get the following message. 'Fatal error: Connection timed out in /opt/bitnami/apache/htdocs/connections/Connection.php on line 626' I don't understand why the connection will work from command line but it's failing in PHP.

Admin 6/11/2020

You need to post the actual error message here.

S
seedavidwork author 6/11/2020

I had two unrelated problems and they are both solved now. I built a new PHP runner project with the new database connection and the app started working on the Azure Web Server. I should have tried this last night when I was having the problems originally.

My local dev VM was actually offline, as soon as I got it online I was also able to connect to the Azure DB from the new project. I don't know if it would have failed with the first version of the project.
Thanks for previous suggestions.