---
title: "How To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization Tips"
lang: "en"
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/post/how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips
---

![Blog post image for How To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization Tips - How to run a MySQL database in a Docker container: starting a container, connecting to it, customizing its configuration, and using volumes for data persistence, plus tips for optimizing your setup. For developers, sysadmins, and database administrators.](/_astro/hero.W_-sxnO__ZHqVWx.webp)

[Home](/)›[Blog](/blog)›[All Categories](/blog/categories)›[Docker](/blog/categories/docker)

Blog

[Prev in DockerHow to Run an Apache Web Server Using Docker on an AWS EC2 Instance](/blog/post/how-to-run-an-apache-web-server-using-docker-on-an-aws-ec2-instance)

[Docker](/blog/categories/docker)[MySQL](/blog/categories/mysql)[Databases](/blog/categories/databases)[DevOps](/blog/categories/devops)[Containerization](/blog/categories/containerization)

# How To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization Tips

[Mohammad Abu Mattar](/authors/mohammad-abu-mattar)Published: 12 Feb 202309 Mins read15 Mins listen

[Markdown for AI(opens in a new tab)](/post/how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips/index.md "Open the plain-Markdown version of this page, for pasting into an AI tool")

TL;DR

How to run a MySQL database in a Docker container: starting a container, connecting to it, customizing its configuration, and using volumes for data persistence, plus tips for optimizing your setup. For developers, sysadmins, and database administrators.

Series

[Docker Essentials](/series/docker-essentials)2/3

[PreviousHow To Install Docker On Linux In 4 Easy Steps](/blog/post/how-to-install-docker-on-linux-in-4-easy-steps)[NextGet Started with Building ReactJS and Docker: A Complete Guide](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

All posts in this series (3)

Blog3

1.  [How To Install Docker On Linux In 4 Easy Steps](/blog/post/how-to-install-docker-on-linux-in-4-easy-steps)
2.  [How To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization TipsYou are here](/blog/post/how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips)
3.  [Get Started with Building ReactJS and Docker: A Complete Guide](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

### How To Run MySQL in a Docker Container: A Step-by-Step Guide with Customization Tips

Contents

[Introduction](#introduction)[Prerequisites](#prerequisites)[Running a MySQL database in a Docker container](#running-a-mysql-database-in-a-docker-container)[Step 1: Running a MySQL container with the docker run command](#step-1-running-a-mysql-container-with-the-docker-run-command)[\# Example](#-example)[Step 2: Connecting to the MySQL container](#step-2-connecting-to-the-mysql-container)[\# Example](#-example)[Step 3: Customizing the MySQL container configuration](#step-3-customizing-the-mysql-container-configuration)[Step 4: Persisting data with Docker volumes](#step-4-persisting-data-with-docker-volumes)[Step 5: Stopping and starting the MySQL container](#step-5-stopping-and-starting-the-mysql-container)[Setting up the compose.yml file](#setting-up-the-composeyml-file)[Conclusion](#conclusion)[References](#references)

## [Introduction](#introduction)

Docker changed the way we run and manage applications by making it easy to package, deploy, and run applications in containers. Containers let applications run in a consistent environment, independent of the host system, which makes them easier to manage and deploy.

MySQL is one of the most widely used databases in the world, and it can be easily run in a Docker container. Running MySQL in a Docker container has several benefits: better portability, easier management, and room to run multiple instances of the database on the same host.

In this article, we’ll cover the basics of running a MySQL database in a Docker container, including how to start a container, connect to it, customize the configuration, and persist data using Docker volumes. We’ll also provide tips for optimizing and customizing your MySQL container setup. Whether you’re a developer, system administrator, or database administrator, this guide will help you get started with using Docker to run and manage your MySQL database.

## [Prerequisites](#prerequisites)

Before you can run a MySQL database in a Docker container, you’ll need to have a few things set up on your machine:

-   Docker: Make sure you have Docker installed on your machine. If you don’t, follow the instructions for your operating system in [How To Install Docker On Linux In 4 Easy Steps](/blog/post/how-to-install-docker-on-linux-in-4-easy-steps).
-   Docker CLI: You’ll also need the Docker CLI installed on your machine. This is included in the Docker installation package for most operating systems.
-   Basic knowledge of Docker: To follow this guide, you should have a basic understanding of how Docker works and how to use the Docker CLI.

Once you have these prerequisites in place, you’re ready to start running a MySQL database in a Docker container.

## [Running a MySQL database in a Docker container](#running-a-mysql-database-in-a-docker-container)

### [Step 1: Running a MySQL container with the docker run command](#step-1-running-a-mysql-container-with-the-docker-run-command)

To run a MySQL container, you can use the Docker run command. The run command is used to start a new container from an image. You can use the official MySQL image from the Docker Hub to start a new container.

The basic syntax of the Docker run command is as follows:

Terminal window

```
1docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
```

To run a MySQL container, you can use the following command:

Terminal window

```
1docker run --name [CONTAINER_NAME] -e MYSQL_ROOT_PASSWORD=[ROOT_PASSWORD] -d mysql
```

Here, we are using the following options:

-   `--name`: This option is used to specify a name for the container. You can replace `[CONTAINER_NAME]` with the name you want to give to the container.
-   `-e`: This option is used to set an environment variable. In this case, we’re setting the `MYSQL_ROOT_PASSWORD` environment variable to the root password for the MySQL database. You can replace `[ROOT_PASSWORD]` with the password you want to use.
-   `-d`: This option is used to run the container in the background.

This command will download the official MySQL image from the Docker Hub, start a new container with the specified name, set the root password, and run the container in the background.

Once the container is running, you can use the Docker ps command to view a list of running containers and verify that your MySQL container is running.

#### [Example](#example)

Here’s an example command that runs a MySQL container with the username mkabumattar and password 121612:

Terminal window

```
1# Run a MySQL container2docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=121612 -e MYSQL_USER=mkabumattar -e MYSQL_PASSWORD=121612 -e MYSQL_DATABASE=mydb -p 33060:3306 -d mysql
```

Here, we’re using the following options:

-   `--name`: This option is used to specify the name of the container. We’re using the name mysql-container in this example.
    
-   `-e`: This option is used to set environment variables for the container. We’re setting the following environment variables in this example:
    
    -   `MYSQL_ROOT_PASSWORD`: This sets the password for the root user. We’re setting this to `121612`.
    -   `MYSQL_USER`: This sets the username for a new user. We’re setting this to `mkabumattar`.
    -   `MYSQL_PASSWORD`: This sets the password for the new user. We’re setting this to `121612`.
    -   `MYSQL_DATABASE`: This creates a new database with the specified name. We’re creating a database named `mydb`.
-   `-p`: This option is used to map a port from the host to the container. We’re mapping port 33060 on the host to port 3306 on the container. This allows us to connect to the MySQL container from the host machine.
    
-   `-d`: This option is used to run the container in the background.
    

When you run this command, Docker will download the MySQL image if it’s not already present on your system and run the container. You can then connect to the MySQL container using the mysql client as described in Step 2.

![Running a MySQL Container](/assets/blog/0040-how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips/running-mysql-container.png)

### [Step 2: Connecting to the MySQL container](#step-2-connecting-to-the-mysql-container)

Once your MySQL container is running, you can connect to it using the MySQL client. The MySQL client is a command-line tool that allows you to interact with the MySQL database.

To connect to the MySQL container, you’ll need to know the hostname and port of the container. The hostname is the name of the container, and the default port for MySQL is 3306.

The basic syntax for connecting to a MySQL container using the MySQL client is as follows:

Terminal window

```
1mysql -u [USERNAME] -p -h [HOSTNAME] -P [PORT]
```

Here, we’re using the following options:

-   `-u`: This option is used to specify the username to use when connecting to the database. By default, the MySQL container uses the root user.
-   `-p`: This option is used to prompt for a password. You’ll need to enter the root password you set when running the container.
-   `-h`: This option is used to specify the hostname of the container. You can replace `[HOSTNAME]` with the name of your container.
-   `-P`: This option is used to specify the port to use when connecting to the container. By default, the MySQL container uses port 3306.

When you run this command, you’ll be prompted for the root password. Once you enter the correct password, you’ll be connected to the MySQL container and can start interacting with the database.

You can then run SQL commands to create databases, tables, and perform other tasks within the MySQL container.

#### [Example](#example-1)

Here’s an example command that connects to the MySQL container using the username mkabumattar and password 121612:

Terminal window

```
1mysql -h 127.0.0.1 -P 33060 -u mkabumattar -p
```

Here, we’re using the following options:

-   `-h`: This option is used to specify the hostname. We’re using the hostname `127.0.0.1`, which is the IP address for localhost.
-   `-P`: This option is used to specify the port. We’re using port `33060`, the host port we mapped to the container’s 3306 when we started it.
-   `-u`: This option is used to specify the username. We’re using the username `mkabumattar` in this example.
-   `-p`: This option is used to prompt for a password.

When you run this command, you’ll be prompted to enter the password for the user. Enter the password `121612` and hit Enter. You should then be connected to the MySQL container and be able to run SQL commands.

![Connecting to a MySQL Container](/assets/blog/0040-how-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips/connecting-to-mysql-container.png)

### [Step 3: Customizing the MySQL container configuration](#step-3-customizing-the-mysql-container-configuration)

By default, the MySQL container uses a set of default configuration options that may not suit your needs. You can customize the configuration by creating a custom my.cnf file and mounting it into the container.

To do this, you’ll need to create a new directory on your host system that will be used to store the custom configuration file. Next, create a my.cnf file in that directory with the desired configuration options.

Here’s an example directory structure for a custom configuration:

Terminal window

```
1/path/to/config2  |- my.cnf
```

In this example, the my.cnf file might contain the following configuration options:

```
1[mysqld]2character-set-server=utf8mb43max_allowed_packet=64M4innodb_log_file_size=256M5innodb_buffer_pool_size=1G
```

Next, when you run the `docker run` command, use the -v option to mount the custom configuration directory into the container. For example:

Terminal window

```
1docker run --name mysql -e MYSQL_ROOT_PASSWORD=121612 -v /path/to/config:/etc/mysql/conf.d -p 33060:3306 -d mysql
```

In this example, we’re mounting the `/path/to/config` directory into the `/etc/mysql/conf.d` directory in the container. This means that the custom `my.cnf` file will be used instead of the default configuration file.

After running the container with the custom configuration, you can verify that the new options are in effect by connecting to the container and running the `SHOW VARIABLES` command. This command will show all of the current MySQL configuration options, and you should see your custom options listed.

### [Step 4: Persisting data with Docker volumes](#step-4-persisting-data-with-docker-volumes)

By default, the data stored in a Docker container is ephemeral, which means that it is not persisted across container restarts. This can be a problem if you need to keep your data intact even if the container is stopped or recreated.

To persist the data, you can store it outside of the container. The `-v` option maps a directory on the host system to a directory in the container, and the data stored there is not deleted when the container is deleted.

To set this up, use the -v option in the docker run command and specify the mapping between the host directory and the container directory. For example:

Terminal window

```
1docker run --name mysql -e MYSQL_ROOT_PASSWORD=121612 -v /path/to/data:/var/lib/mysql -p 3306:3306 -d mysql
```

In this example, the `/path/to/data` directory on the host system is mapped to the `/var/lib/mysql` directory in the container. This means that any data stored in the `/var/lib/mysql` directory in the container will be persisted in the `/path/to/data` directory on the host system.

Once the container is running with that mapping, you can use the `docker inspect` command to check that the mount is there and that the data is being stored in the specified location on the host system.

By keeping the data outside the container, it survives even if the container is deleted or recreated. Additionally, if you need to upgrade the MySQL image or change the configuration, you can simply stop the container, delete it, and recreate it with the new image or configuration, while keeping your data intact.

### [Step 5: Stopping and starting the MySQL container](#step-5-stopping-and-starting-the-mysql-container)

To stop the MySQL container, use the `docker stop` command. For example:

Terminal window

```
1docker stop mysql
```

To start the MySQL container, use the `docker start` command. For example:

Terminal window

```
1docker start mysql
```

## [Setting up the compose.yml file](#setting-up-the-composeyml-file)

If you want to run multiple containers, you can use the compose.yml file to define and run your application. The compose.yml file is a YAML file that defines the services that make up your application. Each service is defined using a set of configuration options that tell Docker how to run the container.

Here’s an example compose.yml file that defines a MySQL container:

compose.yml

```
1version: '3.1'2
3x-common-variables: &common-variables4  MYSQL_ROOT_PASSWORD: 1216125  MYSQL_DATABASE: mydb6  MYSQL_USER: mkabumattar7  MYSQL_PASSWORD: 1216128
9services:10  mysql:11    image: mysql:latest12    container_name: mysql13    ports:14      - 33060:330615    volumes:16      - /path/to/data:/var/lib/mysql17    environment:18      <<: *common-variables19      MYSQL_ROOT_PASSWORD: MYSQL_ROOT_PASSWORD20      MYSQL_HOST: localhost21
22  adminer:23    image: adminer24    container_name: adminer25    ports:26      - 8888:808027    environment:28      <<: *common-variables29      ADMINER_DEFAULT_SERVER: mysql
```

In this example, we’re defining two services: `mysql` and `adminer`. The `mysql` service defines a MySQL container, and the `adminer` service defines an Adminer container. Adminer is a web-based database management tool that can be used to manage MySQL databases.

The `mysql` service defines the following configuration options:

-   `image`: The image to use to create the container. In this case, we’re using the `mysql:latest` image.
-   `container_name`: The name of the container. In this case, we’re using the name `mysql`.
-   `ports`: The port mappings between the host system and the container. In this case, we’re mapping the port 33060 on the host system to the port 3306 in the container.
-   `volumes`: The volume mappings between the host system and the container. In this case, we’re mapping the `/path/to/data` directory on the host system to the `/var/lib/mysql` directory in the container.
-   `environment`: The environment variables to set in the container. In this case, we’re setting the `MYSQL_ROOT_PASSWORD` environment variable to `121612`.

The `adminer` service defines the following configuration options:

-   `image`: The image to use to create the container. In this case, we’re using the `adminer` image.
-   `container_name`: The name of the container. In this case, we’re using the name `adminer`.
-   `ports`: The port mappings between the host system and the container. In this case, we’re mapping the port 8080 on the host system to the port 8080 in the container.
-   `environment`: The environment variables to set in the container. In this case, we’re setting the `MYSQL_ROOT_PASSWORD` environment variable to `121612`, and the `ADMINER_DEFAULT_SERVER` environment variable to `mysql`.

To run the application defined in the compose.yml file, use the `docker-compose up` command. For example:

Terminal window

```
1docker-compose up -d
```

The `-d` option tells Docker to run the containers in the background. If you don’t use the `-d` option, Docker will run the containers in the foreground and will not return control to the terminal until you stop the containers.

To stop the containers, use the `docker-compose down` command. For example:

Terminal window

```
1docker-compose down
```

## [Conclusion](#conclusion)

Docker makes it easy to run and manage applications in containers. Running MySQL in a Docker container is a convenient way to isolate the database from the host system and other containers, while still keeping it accessible from other applications.

In this article, we covered how to run a MySQL container using the `docker run` command, connect to the container, customize the configuration, and persist the data using Docker volumes. Following these steps, you can run a MySQL database in a Docker container and customize it to meet your needs.

Whether you are a developer, a DevOps engineer, or a database administrator, using Docker to run MySQL can simplify your workflow and help you manage your database infrastructure more efficiently.

## [References](#references)

1.  [Docker Official Website - Get Started](https://www.docker.com/get-started)
2.  [MySQL Official Docker Image - Docker Hub](https://hub.docker.com/_/mysql)
3.  [MySQL Documentation](https://dev.mysql.com/doc/)
4.  [Docker Run Command Reference](https://docs.docker.com/engine/reference/commandline/run/)
5.  [Docker Compose Overview](https://docs.docker.com/compose/)
6.  [Manage data in Docker - Docker Volumes](https://docs.docker.com/storage/volumes/)
7.  [MySQL Client Commands](https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html)
8.  [MySQL Server Configuration Defaults](https://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html) (for `my.cnf`)
9.  [Adminer Official Docker Image - Docker Hub](https://hub.docker.com/_/adminer)
10.  “How To Install Docker On Linux In 4 Easy Steps!” (Your previous article) - [/blog/how-to-install-docker-on-linux-in-4-easy-steps](/blog/how-to-install-docker-on-linux-in-4-easy-steps)

Was this useful?

## Tags

[#Docker](/blog/tags/docker)[#MySQL](/blog/tags/mysql)[#Database Containerization](/blog/tags/database-containerization)[#Docker Compose](/blog/tags/docker-compose)[#Data Persistence](/blog/tags/data-persistence)[#Docker Volumes](/blog/tags/docker-volumes)[#DevOps Practices](/blog/tags/devops-practices)

## Share

[Facebook](https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips "Share on Facebook")[Twitter](https://twitter.com/intent/tweet/?text=How%20To%20Run%20MySQL%20in%20a%20Docker%20Container%3A%20A%20Step-by-Step%20Guide%20with%20Customization%20Tips&url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips "Share on Twitter")[LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips&title=How%20To%20Run%20MySQL%20in%20a%20Docker%20Container%3A%20A%20Step-by-Step%20Guide%20with%20Customization%20Tips&summary=How%20to%20run%20a%20MySQL%20database%20in%20a%20Docker%20container%3A%20starting%20a%20container%2C%20connecting%20to%20it%2C%20customizing%20its%20configuration%2C%20and%20using%20volumes%20for%20data%20persistence%2C%20plus%20tips%20for%20optimizing%20your%20setup.%20For%20developers%2C%20sysadmins%2C%20and%20database%20administrators.&source=https://mkabumattar.com "Share on LinkedIn")[WhatsApp](https://wa.me/?text=How%20To%20Run%20MySQL%20in%20a%20Docker%20Container%3A%20A%20Step-by-Step%20Guide%20with%20Customization%20Tips%20https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips "Share on WhatsApp")[Telegram](https://t.me/share/url?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips&text=How%20To%20Run%20MySQL%20in%20a%20Docker%20Container%3A%20A%20Step-by-Step%20Guide%20with%20Customization%20Tips "Share on Telegram")[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips&title=How%20To%20Run%20MySQL%20in%20a%20Docker%20Container%3A%20A%20Step-by-Step%20Guide%20with%20Customization%20Tips "Share on Reddit")[Hacker News](http://news.ycombinator.com/submitlink?u=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips&t=How%20To%20Run%20MySQL%20in%20a%20Docker%20Container%3A%20A%20Step-by-Step%20Guide%20with%20Customization%20Tips "Share on Hacker News")[Pinterest](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips&media=&description=How%20to%20run%20a%20MySQL%20database%20in%20a%20Docker%20container%3A%20starting%20a%20container%2C%20connecting%20to%20it%2C%20customizing%20its%20configuration%2C%20and%20using%20volumes%20for%20data%20persistence%2C%20plus%20tips%20for%20optimizing%20your%20setup.%20For%20developers%2C%20sysadmins%2C%20and%20database%20administrators. "Share on Pinterest")[Email](<mailto:?subject=How%20To%20Run%20MySQL%20in%20a%20Docker%20Container%3A%20A%20Step-by-Step%20Guide%20with%20Customization%20Tips&body=Check out this article: https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-run-mysql-in-a-docker-container-a-step-by-step-guide-with-customization-tips>)

## Comments

## You might also enjoy

More posts on similar topics

[![Get Started with Building ReactJS and Docker: A Complete Guide](/_astro/hero.CDA9gINC_5FejQ.webp)](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

## [Get Started with Building ReactJS and Docker: A Complete Guide](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [ReactJS](/blog/categories/reactjs)
-   [Docker](/blog/categories/docker)
-   [DevOps](/blog/categories/devops)
-   [Containerization](/blog/categories/containerization)
-   [Web Development](/blog/categories/web-development)

Introduction Docker is a powerful tool that allows developers to create, deploy, and run applications in a portable and scalable way. It uses containerization to encapsulate all the dependencies a

[#ReactJS](/blog/tags/reactjs)[#Docker](/blog/tags/docker)[#Dockerfile](/blog/tags/dockerfile)+5 tags

[read more](/blog/post/get-started-with-building-reactjs-and-docker-a-complete-guide)

[![How To Install Docker On Linux In 4 Easy Steps](/_astro/hero.CpX7CDI1_VrFPo.webp)](/blog/post/how-to-install-docker-on-linux-in-4-easy-steps)

## [How To Install Docker On Linux In 4 Easy Steps](/blog/post/how-to-install-docker-on-linux-in-4-easy-steps)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Docker](/blog/categories/docker)
-   [Linux](/blog/categories/linux)
-   [DevOps](/blog/categories/devops)
-   [System Administration](/blog/categories/system-administration)
-   [Containerization](/blog/categories/containerization)

Introduction Docker is a platform that lets developers create, deploy, and run applications in containers. Containers are isolated environments that allow you to run your applications in a consist

[#Docker Installation](/blog/tags/docker-installation)[#Linux Setup](/blog/tags/linux-setup)[#DevOps Tools](/blog/tags/devops-tools)+3 tags

[read more](/blog/post/how-to-install-docker-on-linux-in-4-easy-steps)

[![How to Deploy a Spring Boot Application to AWS CloudFormation](/_astro/hero.C8XnJRc3_Z1OiL51.webp)](/blog/post/how-to-deploy-a-spring-boot-application-to-aws-cloudformation)

## [How to Deploy a Spring Boot Application to AWS CloudFormation](/blog/post/how-to-deploy-a-spring-boot-application-to-aws-cloudformation)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [Spring Boot](/blog/categories/spring-boot)
-   [CloudFormation](/blog/categories/cloudformation)
-   [DevOps](/blog/categories/devops)
-   [Java](/blog/categories/java)

Introduction Deploying a Spring Boot application to the cloud can provide many benefits such as scalability and easy management. AWS CloudFormation is a service that allows for the creation and ma

[#AWS CloudFormation](/blog/tags/aws-cloudformation)[#Spring Boot Deployment](/blog/tags/spring-boot-deployment)[#Java on AWS](/blog/tags/java-on-aws)+5 tags

[read more](/blog/post/how-to-deploy-a-spring-boot-application-to-aws-cloudformation)

[![Becoming an AWS Pro: A Deep Dive into Amazon Elastic Container Service](/_astro/hero.ia7tHPKE_ZlnALL.webp)](/blog/post/aws-ecs-deep-dive)

## [Becoming an AWS Pro: A Deep Dive into Amazon Elastic Container Service](/blog/post/aws-ecs-deep-dive)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [Cloud Computing](/blog/categories/cloud-computing)
-   [DevOps](/blog/categories/devops)
-   [Containerization](/blog/categories/containerization)
-   [ECS](/blog/categories/ecs)

Introduction If you're working on container orchestration on AWS, Amazon Elastic Container Service (ECS) is worth understanding well. This guide covers ECS in depth and answers the most common que

[#AWS ECS](/blog/tags/aws-ecs)[#Amazon EKS](/blog/tags/amazon-eks)[#AWS Fargate](/blog/tags/aws-fargate)+7 tags

[read more](/blog/post/aws-ecs-deep-dive)

[![How to CI/CD AWS With Github using Jenkins](/_astro/hero.B1mpyM8T_14dvIE.webp)](/blog/post/how-to-ci-cd-aws-with-github-using-jenkins)

## [How to CI/CD AWS With Github using Jenkins](/blog/post/how-to-ci-cd-aws-with-github-using-jenkins)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [CI/CD](/blog/categories/cicd)
-   [DevOps](/blog/categories/devops)
-   [AWS](/blog/categories/aws)
-   [Jenkins](/blog/categories/jenkins)
-   [GitHub](/blog/categories/github)

Introduction In a previous post, I showed you how to set up Jenkins on an AWS EC2 instance. You can read that post here. In this post, I will sho

[#CI/CD Pipeline](/blog/tags/cicd-pipeline)[#Jenkins](/blog/tags/jenkins)[#GitHub Integration](/blog/tags/github-integration)+6 tags

[read more](/blog/post/how-to-ci-cd-aws-with-github-using-jenkins)

[![How to Connect to AWS RDS MySQL Database to EC2 Instance With PHP By Using PDO](/_astro/hero.BbyjrsxP_xhG8d.webp)](/blog/post/how-to-connect-to-aws-rds-mysql-database-to-ec2-instance-with-php-by-using-pdo)

## [How to Connect to AWS RDS MySQL Database to EC2 Instance With PHP By Using PDO](/blog/post/how-to-connect-to-aws-rds-mysql-database-to-ec2-instance-with-php-by-using-pdo)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [RDS](/blog/categories/rds)
-   [EC2](/blog/categories/ec2)
-   [PHP](/blog/categories/php)
-   [MySQL](/blog/categories/mysql)
-   [Database](/blog/categories/database)

Introduction In this post, we will learn how to connect an AWS RDS MySQL database to an EC2 instance with PHP, using PDO. PrerequisitesAWS Account EC2 Instance Amazon Linux 2 RDS MySQL

[#AWS RDS MySQL](/blog/tags/aws-rds-mysql)[#EC2 PHP PDO](/blog/tags/ec2-php-pdo)[#Database Connection](/blog/tags/database-connection)+5 tags

[read more](/blog/post/how-to-connect-to-aws-rds-mysql-database-to-ec2-instance-with-php-by-using-pdo)

6 related posts
