question

EdwardJohnson-6850 avatar image
0 Votes"
EdwardJohnson-6850 asked EdwardJohnson-6850 commented

When trying to connect to mySQL: ERROR 2005 (HY000): Unknown MySQL server host

I just set up a new app with App Service using the "db included" option.

However, I'm having trouble importing my database.

Here's the command I am using:

mysql -h mydbname.mysql.database.azure.com -u myusername -p sys

However, I keep getting the following error:

ERROR 2005 (HY000): Unknown MySQL server host 'mydbname.mysql.database.azure.com' (-2)

  • I obtained the Server Name and Server Admin Login Name from the Azure dashboard.

  • I double-checked the password, and when that didn't work, I reset the password and waited for the server to be rebooted and then tried again-- same error.

Some of the docs I looked at (like this one) mention setting up a firewall rule under "Connection security", but I can't find any security options on the admin screen for my database (Azure Database for MySQL flexible server).

Any help on how to get a connection to mySQL would be much appreciated.


azure-webappsazure-webapps-developmentazure-webapps-authentication
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Create a firewall rule and add your Public IP address
Go to the Networking tab to configure how you want to connect to your server.
In the Connectivity method, select Public access (allowed IP addresses). To create the Firewall rules, specify the Firewall rule name and single IP address, or a range of addresses.
https://docs.microsoft.com/en-us/azure/mysql/flexible-server/how-to-manage-firewall-portal

Did you try to make a connection with SSL mode disabled?
First disable SSL enforcement on your flexible server
https://docs.microsoft.com/en-us/azure/mysql/flexible-server/how-to-connect-tls-ssl#disable-ssl-enforcement-on-your-flexible-server


 mysql.exe -h mydemoserver.mysql.database.azure.com -u myadmin -p pass --ssl-mode=DISABLED



0 Votes 0 ·

1 Answer

TakahitoIwasa avatar image
1 Vote"
TakahitoIwasa answered EdwardJohnson-6850 commented

Hi. @EdwardJohnson-6850

Did you use Marketplace's "Web App + Database" to create your resources?

187544-779e8ddf-835e-4619-949f-ccf197bc3c2c-4-5005-c.jpeg

The MySQL server created with this template is VNET integrated and cannot be publicly accessed from the outside.
You also need to do name resolution in your private DNS zone.

187515-0a3ae47e-e004-47b3-9fa9-42d94d487969-1-105-c.jpeg

$ mysql -u mdghqxvlkp -h hogeiwasa-server.mysql.database.azure.com -p sys
Enter password: 
ERROR 2005 (HY000): Unknown MySQL server host 'hogeiwasa-server.mysql.database.azure.com' (8)


Check the following for details.
https://docs.microsoft.com/en-us/azure/mysql/flexible-server/concepts-networking#choosing-a-networking-option

You need to use a VPN or access from within the same VNET via a bastion server on the VNET.

I added Azure Bastion and Virtual Machine to the VNET created by the template and connected.

187593-a362be02-5f1a-4193-a4d2-4ac8ece41c82-4-5005-c.jpeg

hogehoge@hoge-iwasa-vm:~$ mysql -u mdghqxvlkp -h hogeiwasa-server.mysql.database.azure.com -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.36-log MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yes, I'm using Web App + Database. Wow, that's a lot more complicated than I expected. Thank you for your very thorough answer; I'll look into Bastion.

0 Votes 0 ·