Steps to install MySQL using Docker under Linux

Steps to install MySQL using Docker under Linux

As a tester, you may often need to install some software under Linux during the learning process. If you install some software by searching other people's blog tutorials, with the upgrade of some software and external factors such as inconsistent virtual machine/server image versions, various unpredictable problems may occur in the installation of the software. At that time, you have to search for information to solve the problems one by one, which is very time-consuming.

Moreover, the installation of these software under Linux is generally an operation and maintenance matter. If the test is used for learning, it is enough to install a MySQL database for learning. It is not recommended for novices to download source code to install software under Linux, as it is easy to cause problems.

Next, I will show you how to quickly install a MySQL instance through Docker for learning:

1. First, build the docker environment

2. Download the MySQL image and start it (version 5.7 is slightly more stable. Different versions may have different default configurations for some systems, so please pay attention)

Install MySQL via Docker:

 docker pull mysql:5.7

Start mysql:

docker run -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7
#Enter the container docker exec -it mysql bash

Parameter Description:

  • -p 3306:3306: Maps the container service's port 3306 to the host's port 3306. External hosts can directly access the MySQL service through the host's ip:3306.
  • MYSQL_ROOT_PASSWORD=123456: Set the password of the MySQL service root user.

Connect to mysql:

# Enter interactive mode, and then connect using the command, or connect through navicat docker exec -it [container id] bash 
mysql -uroot -h127.0.0.1 -P3306 -p123456

For personal learning and installation of MySQL, it is ok to use the simple parameters above. If you want to consider future upgrades and backups, you need to add other parameters, such as mapping the data to a local directory. After the container is deleted and rebuilt, the data will not be lost. For specific operation methods, you can check the relevant tutorials on the novice tutorial for extended learning.

This is the end of this article about installing MySQL using Docker in Linux. For more information about installing MySQL using Docker in Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Install Docker environment in Linux environment (no pitfalls)
  • Docker installation and deployment example on Linux
  • Golang study notes: Install Go1.15 version (win/linux/macos/docker installation)
  • Detailed explanation of how to install mongodb using docker on linux
  • The process of installing Docker in Linux system

<<:  Solution to HTML2 canvas SVG not being recognized

>>:  Using docker command does not require sudo

Recommend

js to implement file upload style details

Table of contents 1. Overview 2. Parameters for c...

Implementation of postcss-pxtorem mobile adaptation

Execute the command to install the plugin postcss...

CSS optimization skills self-practice experience

1. Use css sprites. The advantage is that the smal...

Zabbix monitors the process of Linux system services

Zabbix automatically discovers rules to monitor s...

Summary of the three stages of visual designer growth

Many people have read this book: "Grow as a ...

How to implement the strategy pattern in Javascript

Table of contents Overview Code Implementation Su...

How to monitor mysql using zabbix

Zabbix deployment documentation After zabbix is ​...

CentOS6.9+Mysql5.7.18 source code installation detailed tutorial

CentOS6.9+Mysql5.7.18 source code installation, t...

Detailed analysis of several situations in which MySQL indexes fail

1. Leading fuzzy query cannot use index (like ...

Web Design Tutorial (7): Improving Web Design Efficiency

<br />Previous article: Web Design Tutorial ...

Installing Win10 system on VMware workstation 14 pro

This article introduces how to install the system...

Detailed introduction to linux host name configuration

Table of contents 1. Configure Linux hostname Con...

About Tomcat combined with Atomikos to implement JTA

Recently, the project switched the environment an...

Implementation of MySQL scheduled backup script under Windows

On a Windows server, if you want to back up datab...

Detailed tutorial on installing harbor private warehouse using docker compose

Overview What is harbor? The English word means: ...