Answered by:
Problems connecting to MySQL Azure from Azure MV in PHP

Question
-
Hello,
New to Azure infrastructure etc so not sure where to post this..
I have an Azure Windows Server 2016 VM where I am hosting a PHP based website which has a MySQL back-end. My database is hosted in an Azure for MySQL instance. I can connect to the database interactively via MySQL Workbench and powershell scripts.
The problem comes when my web pages try to connect, and I think its related to the application pool. Running my website application pool as 'ApplicationPoolIdentity' I get the following error when my PHP code tries to connect:
[MySQL][ODBC 5.3(w) Driver]Unknown MySQL server host 'xxxx.mysql.database.azure.com' (0), SQL state S1000 in SQLConnect in C:\Program Files\xxxx\odbc_test.php on line 5
If I run my application pool as my interactive (local admin) user, then the above code works. I also created a user specifically for running my app pool, but it seems to have to be in the local admins group to work.
If I run a command prompt as my app pool user and execute the same PHP code, then it works. So my problem appears to be related to the non-interactive nature of the web page and the user permissions.
I'd rather not have my app pool user a local admin on the VM, but can't see what the likely user rights assignments or group memberships would be.
Would greatly appreciate any thoughts anyone might have on the matter?
Thanks,
Al.
Monday, July 6, 2020 3:34 PM
Answers
-
The Azure forums have migrated to QnA
https://docs.microsoft.com/en-us/answers/index.html
here you can Ask a question and assign appropriate tags.
https://docs.microsoft.com/en-us/answers/topics.html?sort=name
also try here
https://forums.asp.net/1247.aspx/1?Azure+and+ASP+NET
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.
- Edited by Dave PatrickMVP Monday, July 6, 2020 3:48 PM
- Proposed as answer by Guido Franzke Tuesday, July 7, 2020 5:56 AM
- Marked as answer by Guido Franzke Monday, July 13, 2020 8:41 AM
Monday, July 6, 2020 3:46 PM
All replies
-
The Azure forums have migrated to QnA
https://docs.microsoft.com/en-us/answers/index.html
here you can Ask a question and assign appropriate tags.
https://docs.microsoft.com/en-us/answers/topics.html?sort=name
also try here
https://forums.asp.net/1247.aspx/1?Azure+and+ASP+NET
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.
- Edited by Dave PatrickMVP Monday, July 6, 2020 3:48 PM
- Proposed as answer by Guido Franzke Tuesday, July 7, 2020 5:56 AM
- Marked as answer by Guido Franzke Monday, July 13, 2020 8:41 AM
Monday, July 6, 2020 3:46 PM -
Get the connection information you need to connect to the database in Azure SQL Database. You'll need the fully qualified server name or host name, database name, and login information for the upcoming procedures.
Sign in to the Azure portal.
Navigate to the SQL Databases or SQL Managed Instances page.
On the Overview page, review the fully qualified server name next to Server name for a database in Azure SQL Database or the fully qualified server name (or IP address) next to Host for an Azure SQL Managed Instance or SQL Server in an Azure VM. To copy the server name or host name, hover over it and select the Copy icon.Monday, July 6, 2020 3:51 PM -
Get the connection information you need to connect to the database in Azure SQL Database. You'll need the fully qualified server name or host name, database name, and login information for the upcoming procedures.
Sign in to the Azure portal.
Navigate to the SQL Databases or SQL Managed Instances page.
On the Overview page, review the fully qualified server name next to Server name for a database in Azure SQL Database or the fully qualified server name (or IP address) next to Host for an Azure SQL Managed Instance or SQL Server in an Azure VM. To copy the server name or host name, hover over it and select the Copy icon.Thanks, I have done that, and the information works, but not for certain application pool users..
Al.
Monday, July 6, 2020 5:04 PM