当前位置:网站首页>[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
边栏推荐
- 350. Intersection of two arrays II
- 1805. 字符串中不同整数的数目
- 算法面试经典100题,Android程序员最新职业规划
- [translation] a GPU approach to particle physics
- LeetCode_双指针_中等_61. 旋转链表
- In 50W, what have I done right?
- 打家劫舍III[后序遍历与回溯+动态规划]
- Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
- Learning and Exploration - function anti shake
- In depth analysis, Android interview real problem analysis is popular all over the network
猜你喜欢
Synchronous development of business and application: strategic suggestions for application modernization
IC设计流程中需要使用到的文件
今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发
JDBC详解
Druid database connection pool details
[translation] linkerd's adoption rate in Europe and North America exceeded istio, with an increase of 118% in 2021.
全套教学资料,阿里快手拼多多等7家大厂Android面试真题
Learning and Exploration - Seamless rotation map
学习探索-无缝轮播图
零基础入门PolarDB-X:搭建高可用系统并联动数据大屏
随机推荐
企业精益管理体系介绍
Hudi vs Delta vs Iceberg
VMware virtual machine cannot open the kernel device "\.\global\vmx86"
时钟轮在 RPC 中的应用
三面蚂蚁金服成功拿到offer,Android开发社招面试经验
CPU负载很低,loadavg很高处理方法
Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
Dark horse -- redis
社招面试心得,2022最新Android高频精选面试题分享
Benefit a lot, Android interview questions
spark基础-scala
【翻译】Linkerd在欧洲和北美的采用率超过了Istio,2021年增长118%。
学习探索-无缝轮播图
121. The best time to buy and sell stocks
Use of deg2rad and rad2deg functions in MATLAB
An error occurs when installing MySQL: could not create or access the registry key needed for the
Interview assault 63: how to remove duplication in MySQL?
保证接口数据安全的10种方案
关于图像的读取及处理等
C language daily practice - day 22: Zero foundation learning dynamic planning