MySQL with Docker

Pull MySQL Image

$ docker pull mysql
$ docker pull mysql:8.0.24
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest d4c3cafb11d5 3 months ago 545MB

Run MySQL Image as Container

$ docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=password -d mysql:latest
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
288b789ca408 mysql "docker-entrypoint.s…" 13 days ago Up 4 seconds 3306/tcp, 33060/tcp mysql-container
$ docker stop mysql-container
$ docker start mysql-container

Access MySQL Shell

$ docker exec -it mysql-container /bin/bash
root@288b789ca408:/#
root@288b789ca408:/# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.22 MySQL Community Server - GPL
Copyright (c) 2000, 2020, 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>

Misc

References

A software engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Speedup your Jest tests in GitHub Actions

Cloning Bewakoof: The first of the many projects

Credit Checker: A highly acclaimed credit reporting app

Pandemic-driven Bubble Tea Availability Monitoring w/ Amazon Pinpoint, EventBridge, Lambda & More

How to Create your own Search Engine with Python Language and Laravel Framework Step 3 of 4

Announcing AMQP-on-Pulsar: bring native AMQP protocol support to Apache Pulsar

Python Virtual Environments Enhance Release Quality

Jenkins Industry Use Cases

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lowell Sianipar

Lowell Sianipar

A software engineer

More from Medium

Django ORM(Object–relational mapping) ‘OR’ and ‘AND’ query

MySQL/MyBatis | Using Dynamic Query

How to share docker images without Docker hub or any registry

Install packages from GitHub Packages in CI/CD