Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How can novices build MySQL services quickly?

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how novices build MySQL services quickly". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Description

MySQL 5.6 SQL database server Docker mirror, this container image contains the MySQL 5.6 SQL database server for OpenShift and general usage. Users can select RHEL and CentOS-based images. CentOS images can then be obtained on Docker Hub in the form of centos / mysql-56-centos7.

Usage

For installation and use, please refer to the Docker installation in the previous article.

Find the image:

Docker search mysql

Get the image:

Docker pull docker.io/centos/mysql-56-centos7

If you want to set only the necessary environment variables without storing the database in the host directory, execute the following command:

Docker run-d-- name app_mysql-p 3307 MYSQL_ROOT_PASSWORD=123456 docker.io/centos/mysql-56-centos7 3306-e MYSQL_ROOT_PASSWORD=123456 docker.io/centos/mysql-56-centos7

If you want your database to remain persistent during container execution, execute the following command:

# create a data storage directory and a configuration file directory mkdir-p ~ / home/mysql/data ~ / home/mysql/cnf.d# to grant read and write permissions respectively (this is the key point Otherwise, you cannot create and run the container) chmod + 766 data/chmod + 766 cnf.d/# create and run container docker run-d-- name app_mysql-p 3307 cnf.d/# 3306-v / home/mysql/cnf.d:/etc/my.cnf.d-v / home/mysql/data:/var/lib/mysql/data-e MYSQL_ROOT_PASSWORD=123456 docker.io/centos/mysql-56-centos7

Command description:

-p 3307virtual 3306: map port 3306 of the container to port 3307 of the host

-v / home/mysql/cnf.d:/etc/my.cnf.d: host directory: container directory

-v / home/mysql/data:/var/lib/mysql/data: host directory: container directory

-e MYSQLROOTPASSWORD=123456: initializes the password of the root user

Check the container operation:

Docker ps

Enter the container:

Docker exec-it app_mysql bash

Command description:

-d: detach mode: run in the background

-I: keep STDIN open even if there is no attachment

-t: assign a pseudo terminal

This is the end of the content of "how beginners build MySQL services quickly". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report