How do I install MySQL packages in Linux VM on Azure App Service?

Nguyễn Tuấn Nam 0 Reputation points
2023-03-02T04:47:19.8933333+00:00

Hi everyone, I'm trying to deploy my Django app on Azure for a school project. I've been following this tutorial here but my app uses MySQL instead of Postgre. Everything was going fine until I ran the python manage.py migrate command. It failed with the "Unknown MySQL server host" error. The database server was already up and running, so I tried to connect to the database from the SSH terminal and got this. And even if I could install the package on the machine won't it be temporarily only since the data outside of /home is not persisted. Can anyone tell me how to deal with this? Thanks a lot!

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
710 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,829 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Manu Philip 16,966 Reputation points MVP
    2023-03-02T06:32:06.3466667+00:00

    The document says it uses a database installed in your local machine. The parameters are added in .env file to support the connection request. I see that you are following a different procedure. Can you clarify that

    0 comments No comments

  2. VenkateshDodda-MSFT 18,021 Reputation points Microsoft Employee
    2023-03-06T07:57:41.9266667+00:00

    @Nguyễn Tuấn Nam Thank you for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.
    Looking at the tutorial shared we understand that you are using blessed image in your app service, and it is not recommended to install the database server on app service and App service are designed to build and host your web application.

    Based on the screenshot shared, we see that you are trying to install mysql server on the app service(sudo is not supported in the ssh kudu console) if you want to install mysql-server then I would suggest you create a custom container (building with custom image using docker) and host it on app service.

    You can also create a Mysql database on Azure and connect to it using python as mentioned here.
    Feel free to reach back to me if you have any further questions on this.

    0 comments No comments