Deploy MySQL


MySQL is a popular database powering many of the highest traffic sites in the world. Render Disks make it effortless to deploy production-grade MySQL on Render backed by high performing SSD disks with automatic snapshots so your data is protected against database restarts and failures.

Render private services are only visible to other Render services in your account. They have internal URLs like mysql:3306, can speak any protocol and can listen on any port. Render automatically detects the ports for your services when they are deployed.

Let’s get started!

MySQL Versions

The master branch for Render’s MySQL repo runs MySQL 8. If you need MySQL 5, make sure to select the mysql-5 branch when you create your service below.

Deployment

  1. Fork render-examples/mysql on GitHub or click the green ‘Use this template’ button.
  2. Create a new Private Service on Render, and give Render permission to access your new repo.

    Pick the mysql-5 branch in this step if you want to deploy MySQL 5.
  3. Use Docker for the Environment and add the following environment variables under Advanced:

    KeyValue
    MYSQL_DATABASEmysql (or your preferred database name)
    MYSQL_USERmysql (or your preferred DB username)
    MYSQL_PASSWORDA secure password for MYSQL_USER
    MYSQL_ROOT_PASSWORDA secure password for the MySQL root user
  4. Add a Disk under Advanced with the following values:

    Namemysql
    Mount Path/var/lib/mysql
    Size10 GB Feel free to change this to match your requirements.

That’s it! Save your private service to bring up MySQL which will take a few minutes to start. Future deploy should be much faster.

Your MySQL instance will be available on the displayed URL as soon as the deploy is live. The URL should look like mysql-foo:3306.

MySQL


You can use the shell in your dashboard to connect to your database.

bash-4.2# mysql -h mysql-demo -D $MYSQL_DATABASE -u $MYSQL_USER --password=$MYSQL_PASSWORD
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 92
Server version: 8.0.17 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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>

You can now connect to MySQL from other applications running in your Render account using the name and port for your private service. Learn more about connecting to MySQL.

You can also create a web service to manage your MySQL database using Adminer. See our Adminer Deployment Guide for details.