当前位置: 首页 > article >正文

容器化部署MySQL5.7数据库

 数据持久化

# 创建数据目录
data]# ls
mysql  mysql_conf  nginx

# 配置文件 中增加了字符集的配置
data]# cd mysql_conf/
[root@data-visualization-010050101050-security mysql_conf]# ls
my.cnf
[root@data-visualization-010050101050-security mysql_conf]# cat my.cnf 
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
secure-file-priv=/var/lib/mysql-files
user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

#log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# 增加配置文件
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci

[client]
socket=/var/run/mysqld/mysqld.sock
# 增加配置文件
default-character-set=utf8mb4

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

创建容器服务 

# 创建容器服务,挂载数据文件和配置文件,运行以下命令
docker run -d --restart=always -e LANG=C.UTF-8 -e TZ=Asia/Shanghai -v /data/mysql_conf/my.cnf:/etc/my.cnf -v /data/mysql:/var/lib/mysql --name=mysql_master -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123123 harbor.dazhenyun.cn/repo/mysql:5.7

 验证新建的容器化MySQL服务

# 进入容器 验证账号密码和字符集配置
bash-4.2# mysql -uroot -p123123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW VARIABLES LIKE 'character_set_server';
+----------------------+---------+
| Variable_name        | Value   |
+----------------------+---------+
| character_set_server | utf8mb4 |
+----------------------+---------+
1 row in set (0.00 sec)

mysql> SHOW VARIABLES LIKE 'collation_server';
+------------------+--------------------+
| Variable_name    | Value              |
+------------------+--------------------+
| collation_server | utf8mb4_unicode_ci |
+------------------+--------------------+
1 row in set (0.00 sec)

mysql> exit
Bye


http://www.kler.cn/a/502875.html

相关文章:

  • 《自动驾驶与机器人中的SLAM技术》ch9:自动驾驶车辆的离线地图构建
  • Oracle FLOOR函数的用法
  • Docker安装和卸载(centos)
  • MySQL的安装
  • 【ROS2】☆ launch之Python
  • mermaid大全(语法、流程图、时序图、甘特图、饼图、用户旅行图、类图)
  • 将Docker运行中的容器保存为镜像并导出导入
  • 移动 web :平面转换,渐变
  • AI多模态技术介绍:视觉语言模型(VLMs)指南
  • Docker安装和卸载(centos)
  • SOLID原则学习,接口隔离原则(Interface Segregation Principle, ISP)
  • halcon3d 如何计算平面法向量!确实很简单
  • ros2-6.4.4 两轮差速控制机器人的问题
  • MATLAB编程实用技巧深度解析
  • 1Hive概览
  • Redis 3 种特殊数据类型
  • CentOS 8 如何安装java与mysql
  • MySQL 最新数据库查询指南
  • springMVC百宝箱
  • [免费]SpringBoot+Vue新能源汽车充电桩管理系统【论文+源码+SQL脚本】
  • 《AI模型格局演变:Claude、Gemini Flash与OpenAI的技术角力》
  • python 3个线程轮流打印A、B、C
  • ElasticSearch 认识和安装ES
  • Mysql--架构篇--存储引擎InnoDB(内存结构,磁盘结构,存储结构,日志管理,锁机制,事务并发控制等)
  • 【深度学习】SAB:空间注意力
  • 【深度学习】数据操作入门