轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像
交易
充值流量¥7起我的订单
文档
工具
提交工单页面收录
mysql-57-centos7

centos/mysql-57-centos7

centos

MySQL 5.7 SQL数据库服务器容器镜像,适用于OpenShift和一般用途,支持RHEL、CentOS和Fedora基础镜像,提供环境变量配置、数据持久化及扩展功能。

94 次收藏下载次数: 0状态:社区镜像维护者:centos仓库类型:镜像最近更新:6 年前
让 AI 帮你使用轩辕镜像? · 展开查看说明 · 点击收起说明

如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。

只需在 AI 对话中先发送下面这句话即可:

请先完整阅读并严格遵守以下文档中的全部规则与要求:

https://xuanyuan.cloud/agents.md

在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。

查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。

DockerHub 官方简介
轩辕镜像中文简介
下载命令
镜像标签列表与下载命令
轩辕镜像,让镜像更快,让人生更轻。
点击查看

MySQL 5.7 SQL Database Server container image

This container image includes MySQL 5.7 SQL database server for OpenShift and general usage. Users can choose between RHEL, CentOS and Fedora based images. The RHEL images are available in the Red Hat Container Catalog, the CentOS images are available on https://hub.docker.com/r/centos/, and the Fedora images are available in https://registry.fedoraproject.org/. The resulting image can be run using https://github.com/containers/libpod.

Note: while the examples in this README are calling podman, you can replace any such calls by docker with the same arguments.

Description

This container image provides a containerized packaging of the MySQL mysqld daemon and client application. The mysqld server daemon accepts connections from clients and provides access to content from MySQL databases on behalf of the clients. You can find more information on the MySQL project from the project Web site (https://www.mysql.com/).

Usage

For this, we will assume that you are using the MySQL 5.7 container image from the Red Hat Container Catalog called rhscl/mysql-57-rhel7. If you want to set only the mandatory environment variables and not store the database in a host directory, execute the following command:

$ podman run -d --name mysql_database -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhscl/mysql-57-rhel7

This will create a container named mysql_database running MySQL with database db and user with credentials user:pass. Port 3306 will be exposed and mapped to the host. If you want your database to be persistent across container executions, also add a -v /host/db/path:/var/lib/mysql/data argument. This will be the MySQL data directory.

If the database directory is not initialized, the entrypoint script will first run https://dev.mysql.com/doc/refman/en/mysql-install-db.html and setup necessary database users and passwords. After the database is initialized, or if it was already present, mysqld is executed and will run as PID 1. You can stop the detached container by running podman stop mysql_database.

Environment variables and volumes

The image recognizes the following environment variables that you can set during initialization by passing -e VAR=VALUE to the Docker run command.

MYSQL_USER
User name for MySQL account to be created

MYSQL_PASSWORD
Password for the user account

MYSQL_DATABASE
Database name

MYSQL_ROOT_PASSWORD
Password for the root user (optional)

The following environment variables influence the MySQL configuration file. They are all optional.

MYSQL_LOWER_CASE_TABLE_NAMES (default: 0)
Sets how the table names are stored and compared

MYSQL_MAX_CONNECTIONS (default: 151)
The maximum permitted number of simultaneous client connections

MYSQL_MAX_ALLOWED_PACKET (default: 200M)
The maximum size of one packet or any generated/intermediate string

MYSQL_FT_MIN_WORD_LEN (default: 4)
The minimum length of the word to be included in a FULLTEXT index

MYSQL_FT_MAX_WORD_LEN (default: 20)
The maximum length of the word to be included in a FULLTEXT index

MYSQL_AIO (default: 1)
Controls the innodb_use_native_aio setting value in case the native AIO is broken. See [***]

MYSQL_TABLE_OPEN_CACHE (default: 400)
The number of open tables for all threads

MYSQL_KEY_BUFFER_SIZE (default: 32M or 10% of available memory)
The size of the buffer used for index blocks

MYSQL_SORT_BUFFER_SIZE (default: 256K)
The size of the buffer used for sorting

MYSQL_READ_BUFFER_SIZE (default: 8M or 5% of available memory)
The size of the buffer used for a sequential scan

MYSQL_INNODB_BUFFER_POOL_SIZE (default: 32M or 50% of available memory)
The size of the buffer pool where InnoDB caches table and index data

MYSQL_INNODB_LOG_FILE_SIZE (default: 8M or 15% of available memory)
The size of each log file in a log group

MYSQL_INNODB_LOG_BUFFER_SIZE (default: 8M or 15% of available memory)
The size of the buffer that InnoDB uses to write to the log files on disk

MYSQL_DEFAULTS_FILE (default: /etc/my.cnf)
Point to an alternative configuration file

MYSQL_BINLOG_FORMAT (default: statement)
Set sets the binlog format, supported values are row and statement

MYSQL_LOG_QUERIES_ENABLED (default: 0)
To enable query logging set this to 1

You can also set the following mount points by passing the -v /host:/container flag to Docker.

/var/lib/mysql/data
MySQL data directory

Notice: When mouting a directory from the host into the container, ensure that the mounted directory has the appropriate permissions and that the owner and group of the directory matches the user UID or name which is running inside the container.

MySQL auto-tuning

When the MySQL image is run with the --memory parameter set and you didn't specify value for some parameters, their values will be automatically calculated based on the available memory.

MYSQL_KEY_BUFFER_SIZE (default: 10%)
key_buffer_size

MYSQL_READ_BUFFER_SIZE (default: 5%)
read_buffer_size

MYSQL_INNODB_BUFFER_POOL_SIZE (default: 50%)
innodb_buffer_pool_size

MYSQL_INNODB_LOG_FILE_SIZE (default: 15%)
innodb_log_file_size

MYSQL_INNODB_LOG_BUFFER_SIZE (default: 15%)
innodb_log_buffer_size

MySQL root user

The root user has no password set by default, only allowing local connections. You can set it by setting the MYSQL_ROOT_PASSWORD environment variable. This will allow you to login to the root account remotely. Local connections will still not require a password.

To disable remote root access, simply unset MYSQL_ROOT_PASSWORD and restart the container.

Changing passwords

Since passwords are part of the image configuration, the only supported method to change passwords for the database user (MYSQL_USER) and root user is by changing the environment variables MYSQL_PASSWORD and MYSQL_ROOT_PASSWORD, respectively.

Changing database passwords through SQL statements or any way other than through the environment variables aforementioned will cause a mismatch between the values stored in the variables and the actual passwords. Whenever a database container starts it will reset the passwords to the values stored in the environment variables.

Default my.cnf file

With environment variables we are able to customize a lot of different parameters or configurations for the mysql bootstrap configurations. If you'd prefer to use your own configuration file, you can override the MYSQL_DEFAULTS_FILE env variable with the full path of the file you wish to use. For example, the default location is /etc/my.cnf but you can change it to /etc/mysql/my.cnf by setting MYSQL_DEFAULTS_FILE=/etc/mysql/my.cnf

Extending image

This image can be extended in Openshift using the Source build strategy or via the standalone https://github.com/openshift/source-to-image application (where available). For this, we will assume that you are using the rhscl/mysql-57-rhel7 image, available via mysql:5.7 imagestream tag in Openshift.

For example, to build a customized MySQL database image my-mysql-rhel7 with a configuration from https://github.com/sclorg/mysql-container/tree/master/examples/extend-image run:

$ oc new-app mysql:5.7~https://github.com/sclorg/mysql-container.git \
	--name my-mysql-rhel7 \
	--context-dir=examples/extend-image \
	--env MYSQL_OPERATIONS_USER=opuser \
	--env MYSQL_OPERATIONS_PASSWORD=oppass \
	--env MYSQL_DATABASE=opdb \
	--env MYSQL_USER=user \
	--env MYSQL_PASSWORD=pass

or via s2i:

$ s2i build --context-dir=examples/extend-image https://github.com/sclorg/mysql-container.git rhscl/mysql-57-rhel7 my-mysql-rhel7

The directory passed to Openshift can contain these directories:

mysql-cfg/ When starting the container, files from this directory will be used as a configuration for the mysqld daemon. envsubst command is run on this file to still allow customization of the image using environmental variables

mysql-pre-init/ Shell scripts (*.sh) available in this directory are sourced before mysqld daemon is started.

mysql-init/ Shell scripts (*.sh) available in this directory are sourced when mysqld daemon is started locally. In this phase, use ${mysql_flags} to connect to the locally running daemon, for example mysql $mysql_flags < dump.sql

Variables that can be used in the scripts provided to s2i:

$mysql_flags arguments for the mysql tool that will connect to the locally running mysqld during initialization

$MYSQL_RUNNING_AS_MASTER variable defined when the container is run with run-mysqld-master command

$MYSQL_RUNNING_AS_SLAVE variable defined when the container is run with run-mysqld-slave command

$MYSQL_DATADIR_FIRST_INIT variable defined when the container was initialized from the empty data dir

During s2i build all provided files are copied into /opt/app-root/src directory into the resulting image. If some configuration files are present in the destination directory, files with the same name are overwritten. Also only one file with the same name can be used for customization and user provided files are preferred over default files in /usr/share/container-scripts/mysql/- so it is possible to overwrite them.

Same configuration directory structure can be used to customize the image every time the image is started using podman run. The directory has to be mounted into /opt/app-root/src/ in the image (-v ./image-configuration/:/opt/app-root/src/). This overwrites customization built into the image.

Securing the connection with SSL

In order to secure the connection with SSL, use the extending feature described above. In particular, put the SSL certificates into a separate directory:

sslapp/mysql-certs/server-cert-selfsigned.pem
sslapp/mysql-certs/server-key.pem

And then put a separate configuration file into mysql-cfg:

$> cat sslapp/mysql-cfg/ssl.cnf
[mysqld]
ssl-key=${APP_DATA}/mysql-certs/server-key.pem
ssl-cert=${APP_DATA}/mysql-certs/server-cert-selfsigned.pem

Such a directory sslapp can then be mounted into the container with -v, or a new container image can be built using s2i.

Upgrading and data directory version checking

MySQL and MariaDB use versions that consist of three numbers X.Y.Z (e.g. 5.6.23). For version changes in Z part, the server's binary data format stays compatible and thus no special upgrade procedure is needed. For upgrades from X.Y to X.Y+1, *** doing manual steps as described at https://dev.mysql.com/doc/refman/5.7/en/upgrading-from-previous-series.html.

Skipping versions like from X.Y to X.Y+2 or downgrading to lower version is not supported; the only exception is ugrading from MariaDB 5.5 to MariaDB 10.0.

Important: Upgrading to a new version is always risky and users are expected to make a full back-up of all data before.

A safer solution to upgrade is to dump all data using mysqldump or mysqldbexport and then load the data using mysql or mysqldbimport into an empty (freshly initialized) database.

Another way of proceeding with the upgrade is starting the new version of the mysqld daemon and run mysql_upgrade right after the start. This so called in-place upgrade is generally faster for large data directory, but only possible if upgrading from the very previous version, so skipping versions is not supported.

This container detects whether the data needs to be upgraded using mysql_upgrade and we can control it by setting MYSQL_DATADIR_ACTION variable, which can have one or more of the following values:

  • upgrade-warn -- If the data version can be determined and the data come from a different version of the daemon, a warning is printed but the container starts. This is the default value. Since historically the version file mysql_upgrade_info was not created, when using this option, the version file is created if not exist, but no mysql_upgrade will be called. However, this automatic creation will be removed after few months, since the version should be created on most deployments at that point.
  • upgrade-auto -- mysql_upgrade is run at the beginning of the container start, when the local daemon is running, but only if the data version can be determined and the data come with the very previous version. A warning is printed if the data come from even older or newer version. This value effectively enables automatic upgrades, but it is always risky and users should still back-up all the data before starting the newer container. Set this option only if you have very good back-ups at any moment and you are fine to fail-over from the back-up.
  • upgrade-force -- mysql_upgrade --force is run at the beginning of the container start, when the local daemon is running, no matter what version of the daemon the data come from. This is also the way to create the missing version file mysql_upgrade_info if not present in the root of the data directory; this file holds information about the version of the data.

There are also some other actions that you may want to run at the beginning of the container start, when the local daemon is running, no matter what version of the data is detected:

  • optimize -- runs mysqlcheck --optimize. It optimizes all the tables.
  • analyze -- runs mysqlcheck --analyze. It analyzes all the tables.
  • disable -- nothing is done regarding data directory version.

Multiple values are separated by comma and run in-order, e.g. MYSQL_DATADIR_ACTION="optimize,analyze".

Changing the replication binlog_format

Some applications may wish to use row binlog_formats (for example, those built with change-data-capture in mind). The default replication/binlog format is statement but to change it you can set the MYSQL_BINLOG_FORMAT environment variable. For example MYSQL_BINLOG_FORMAT=row. Now when you run the database with master replication turned on (ie, set the Docker/container cmd to be run-mysqld-master) the binlog will emit the actual data for the rows that change as opposed to the statements (ie, DML like insert...) that caused the change.

Troubleshooting

The mysqld deamon in the container logs to the standard output, so the log is available in the container log. The log can be examined by running:

podman logs <container>

See also

Dockerfile and other sources for this container image are available on https://github.com/sclorg/mysql-container. In that repository, the Dockerfile for CentOS is called Dockerfile, the Dockerfile for RHEL7 is called Dockerfile.rhel7, the Dockerfile for RHEL8 is called Dockerfile.rhel8, and the Dockerfile for Fedora is called Dockerfile.fedora.

更多相关 Docker 镜像与资源

以下是 centos/mysql-57-centos7 相关的常用 Docker 镜像,适用于 不同场景 等不同场景:

  • library/mysql Docker 镜像说明
  • bitnami/mysql Docker 镜像说明(企业级配置,适合生产环境)
  • alpine/mysql Docker 镜像说明(基于 Alpine Linux,体积更小)
  • bitnamicharts/mysql Docker 镜像说明(Bitnami MySQL 图表版本)
  • iwfwebsolutions/mysql Docker 镜像说明(MySQL 数据库服务)

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 mysql-57-centos7 镜像标签

docker pull docker.xuanyuan.run/centos/mysql-57-centos7:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull centos/mysql-57-centos7:<标签>

轩辕镜像配置手册

按平台快速找到配置文档

Docker

登录仓库拉取

登录认证 · 私有仓库

专属域名拉取

免登录 · 高速拉取

Linux

Docker 镜像配置

Windows / Mac

Docker Desktop 配置

MacOS OrbStack

OrbStack 容器

Apple Container

macOS 原生容器

Docker Compose

Compose 项目配置

NAS

群晖

Synology 配置

飞牛

fnOS 镜像配置

绿联

绿联 NAS

威联通

QNAP 配置

极空间

极空间 NAS

Unraid

Unraid NAS

企业仓库

其他仓库

ghcr · Quay · nvcr

Harbor 镜像源

Proxy Repository 对接

Portainer 镜像源

Registries 配置

Nexus 镜像源

Docker Proxy 缓存

开发工具

Dev Containers

VS Code 开发容器

Podman

Podman 配置指南

Singularity / Apptainer

HPC 科学计算容器

Kubernetes

K8s Containerd

Kubernetes · Containerd

K3s

轻量级集群

面板 / 网络

爱快路由

iKuai 镜像加速

宝塔面板

一键配置镜像源

AI

用 AI 使用轩辕镜像

agents.md · AI 对话 · 提示词

一键安装

一键安装 Docker

Linux Docker 一键安装

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

功能

版本功能对比

功能对比 · 版本选择

支持的镜像仓库

Docker Hub · GCR · GHCR

新手拉取配置

登录 · 专属域名 · 配置

docker search 限制

专属域名 · Hub 搜索

不支持 push

仅支持 pull · 不支持

拉取速度原因

带宽 · 缓存 · 冷热镜像

错误码

402 与流量用尽

402 · 流量包 · 充值

401 认证失败

401 · docker login

manifest unknown

标签错误 · 镜像不存在

410 Gone 排查

410 · Docker 升级

429 限流

免费版 · 请求频率

其他报错

DNS 超时

DNS 解析 · 网络超时

TLS 证书失败

no matching manifest(架构)

账号

失败是否计费

manifest · blob · 计费

申请开发票(企业 / 个人)

企业 · 个人 · 工单

修改登录密码

网站 · 仓库 · 重置

注销账户

工单 · 数据 · 注销

原理

mirrors 不生效

daemon.json · 重启

去掉域名前缀

docker tag · 重命名

指定架构拉取

ARM64 · AMD64 · 多架构

latest 与「最新」

digest · 版本号 · 标签

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
centos/mysql-57-centos7
教程轩辕镜像功能与使用教程
定价查看流量套餐与价格
热门查看热门 Docker 镜像推荐
博客Docker 镜像公告与技术博客
专业版 · 高速稳定拉取镜像
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
50GB 仅 ¥7/年
专业版 · 高速稳定拉取镜像
50GB 仅 ¥7/年
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
商务合作:点击复制邮箱
用户协议·隐私政策·©2024-2026 源码跳动
用户协议·隐私政策©2024-2026 杭州源码跳动科技有限公司商务合作:点击复制邮箱

更多 mysql-57-centos7 镜像推荐

centos logo

library/centos

Docker 官方镜像
已弃用;CentOS的官方版本,该版本此前作为基于红帽企业Linux(RHEL)源代码构建的社区企业级Linux发行版,以稳定、可靠的特性广泛应用于服务器及企业级应用场景,目前已停止官方维护与更新支持。
7.8千 次收藏10亿+ 次下载
3 年前更新
corpusops/centos logo

corpusops/centos

corpusops
corpusops基于CentOS的基础镜像,用于构建和部署应用的基础环境。
4.3千+ 次下载
5 年前更新
dockette/centos logo

dockette/centos

dockette
基于CentOS 5、6、7的基础Docker镜像,包含预定义用户dfx(UID 1000)及常量(USER_UID、USER_NAME、USER_HOME),并针对减小镜像体积进行优化,适用于构建基于CentOS的应用环境。
1 次收藏2.5千+ 次下载
5 年前更新
eclipse/centos logo

eclipse/centos

eclipse
基于CentOS的最小化环境,仅集成git和openssh,适用于需要轻量版本控制系统和SSH服务的场景。
1 次收藏3.1千+ 次下载
8 年前更新
centos/postgresql-10-centos7 logo

centos/postgresql-10-centos7

centos
PostgreSQL是一款高级的对象-关系型数据库管理系统,它开源免费,全面支持SQL标准及扩展功能,提供复杂数据类型(如JSON、数组、地理信息)、强大的事务处理与ACID特性,具备高度可定制性与扩展性,支持高级索引、全文搜索及并发控制,广泛应用于企业级应用、数据仓库、Web开发等领域,以稳定性、安全性和高性能著称。
21 次收藏5000万+ 次下载
4 年前更新
centos/redis-5-centos8 logo

centos/redis-5-centos8

centos
暂无描述
5000万+ 次下载
5 年前更新

查看更多 mysql-57-centos7 相关镜像