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

Introduction to the use of anchors (named anchors) in HTML web pages

The following information is compiled from the Int...

Install and configure ssh in CentOS7

1. Install openssh-server yum install -y openssl ...

Navigation Design and Information Architecture

<br />Most of the time when we talk about na...

Detailed explanation of how to use the vue verification code component

This article example shares the specific implemen...

Tutorial on using iostat command in Linux

Preface It is said that if the people doing opera...

Website redesign is a difficult task for every family

<br />Every family has its own problems, and...

How to import CSS styles into HTML external style sheets

The link-in style is to put all the styles in one...

How to use mixins in Vue

Table of contents Preface How to use Summarize Pr...

A complete guide on how to query and delete duplicate records in MySQL

Preface This article mainly introduces the method...

Detailed explanation of the update command for software (library) under Linux

When installing packages on an Ubuntu server, you...

Implementing WeChat tap animation effect based on CSS3 animation attribute

Seeing the recent popular WeChat tap function, I ...

WeChat applet implements simple calculator function

This article shares the specific code for the WeC...

Implementation of deploying war package project using Docker

To deploy war with Docker, you must use a contain...