当前位置:网站首页>[play with Linux] [docker] MySQL installation and configuration
[play with Linux] [docker] MySQL installation and configuration
2022-07-06 19:37:00 【0xYGC】
brief introduction
Not recommended in docker Running in MySQL Database software , Use only when tests or data are of low importance . It is recommended to install in the production environment KVM
Method / step
One : install MySQL
# see docker edition
docker -v
--------------------------------------------
[[email protected] /]# docker -v
Docker version 1.13.1, build 7d71120/1.13.1
--------------------------------------------
1.1 Search view available MySQL
docker search mysql
1.2 Pull MySQL Mirror image
# Specify the version
docker pull mysql:5.7
# The latest version
docker pull mysql:latest
1.3 View local image
docker images
--------------------------------------------------------------------------------------------
[[email protected] /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql 5.7 efa50097efbd 7 days ago 462 MB
--------------------------------------------------------------------------------------------
1.4 Run container
Default port number 5306
Be careful docker Parameters should be listed in MySQL Before the parameters
docker run \
-p 5306:3306 \
--privileged=true \
--name mysql5306 \
-v /docker/mysql5306/conf:/etc/mysql/conf.d \
-v/docker/mysql5306/logs:/logs \
-v/docker/mysql5306/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=useradmin \
-d mysql:5.7
- The successful running
Two : modify Docker (MySQL) Related configuration
Find the configuration directory of the container
My configuration directory /docker/mysql5306/conf
edit my.cnf If there is no file, create one
- Default profile
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
# Database default character set
character-set-server = utf8mb4
# The database character set corresponds to some sorting rules , Pay attention to and character-set-server Corresponding
collation-server = utf8mb4_general_ci
# Set up client Connect mysql Character set of time , Prevent confusion code
init_connect=‘SET NAMES utf8mb4‘
# Whether the sql Sentence case sensitive ,1 Indicates insensitivity
lower_case_table_names = 1
- Restart container
docker restart [ Target container id]
3、 ... and : Delete Docker Containers
# see docker Container log ,
docker logs ${id}
# One 、 Look at the container , Copy container id namely container id
docker ps -a
# Two 、 Stop container
docker stop Your container id
# 3、 ... and 、 Restart container
docker restart Your container id
# 3、 ... and 、 Delete container
docker rm Containers id
# Four 、 Look at the mirror image , Copy the image id namely images id
docker images
# 5、 ... and . delete mirror
docker rmi Mirror image id
Reference material & thank
[1] docker Modify the container configuration file 3 Summary of methods
边栏推荐
- 思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
- 理解 YOLOV1 第二篇 预测阶段 非极大值抑制(NMS)
- 算法面试经典100题,Android程序员最新职业规划
- Solution of intelligent management platform for suppliers in hardware and electromechanical industry: optimize supply chain management and drive enterprise performance growth
- Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
- 学习探索-使用伪元素清除浮动元素造成的高度坍塌
- zabbix 代理服务器 与 zabbix-snmp 监控
- Fast power template for inverse element, the role of inverse element and example [the 20th summer competition of Shanghai University Programming League] permutation counting
- 全套教学资料,阿里快手拼多多等7家大厂Android面试真题
- Cereals Mall - Distributed Advanced p129~p339 (end)
猜你喜欢
Detailed idea and code implementation of infix expression to suffix expression
利用 clip-path 绘制不规则的图形
Don't miss this underestimated movie because of controversy!
Solution of commercial supply chain management platform for packaging industry: layout smart supply system and digitally integrate the supply chain of packaging industry
spark基础-scala
LeetCode-1279. Traffic light intersection
Interview assault 63: how to remove duplication in MySQL?
【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
黑马--Redis篇
Teach you to learn JS prototype and prototype chain hand in hand, a tutorial that monkeys can understand
随机推荐
受益匪浅,安卓面试问题
Translation D28 (with AC code POJ 26:the nearest number)
121. The best time to buy and sell stocks
Dark horse -- redis
Help improve the professional quality of safety talents | the first stage of personal ability certification and assessment has been successfully completed!
LeetCode-1279. Traffic light intersection
MySQL must know and learn
Solution of commercial supply chain management platform for packaging industry: layout smart supply system and digitally integrate the supply chain of packaging industry
MATLAB中deg2rad和rad2deg函数的使用
Li Kou 101: symmetric binary tree
DaGAN论文解读
Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
反射及在运用过程中出现的IllegalAccessException异常
Spark foundation -scala
[translation] Digital insider. Selection process of kubecon + cloudnativecon in Europe in 2022
腾讯Android面试必问,10年Android开发经验
终于可以一行代码也不用改了!ShardingSphere 原生驱动问世
【翻译】数字内幕。KubeCon + CloudNativeCon在2022年欧洲的选择过程
Swagger2 reports an error illegal DefaultValue null for parameter type integer
Phoenix Architecture 3 - transaction processing