mysql 8.0.27-docker

安装

可以略过本步

https://dev.mysql.com/downloads/https://dev.mysql.com/downloads/

镜像查询与安装

先查询:

docker search mysql
明显会报错

    
Error response from daemon: Get "https://index.docker.io/v1/search?q=mysql&n=25": dial tcp 173.208.182.68:443: i/o timeout

不管三七二十一  docker pull mysql

创建映射文件夹

mkdir -p /home/mysql/log
mkdir -p /home/mysql/data
mkdir -p /home/mysql/conf
 

vim /home/mysql/conf/my.cnf
 

参考【10分钟轻松部署,通过Docker部署MySQL8.3.0数据库】_docker mysql-优快云博客

[client]
#设置客户端默认字符集utf8mb4
default-character-set=utf8mb4
[mysql]
#设置服务器默认字符集为utf8mb4
default-character-set=utf8mb4
[mysqld]
#配置服务器的服务号,具备日后需要集群做准备
server-id = 1
#开启MySQL数据库的二进制日志,用于记录用户对数据库的操作SQL语句,具备日后需要集群做准备
# log-bin=mysql-bin
#设置清理超过30天的日志,以免日志堆积造过多成服务器内存爆满。2592000秒等于30天的秒数
binlog_expire_logs_seconds = 2592000
#解决MySQL8.0版本GROUP BY问题
# sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
#允许最大的连接数
max_connections=1000
# 禁用符号链接以防止各种安全风险
# symbolic-links=0
# 设置东八区时区
default-time_zone = '+8:00'

#不检查赋值目录
secure_file_priv=


 赋予权限

        chmod -R 755 "/home/mysql/"

创建docker

docker run \
-p 3306:3306 \
--restart=always \
--name mysql \
--privileged=true \
-v /home/mysql/log:/var/log/mysql \
-v /home/mysql/data:/var/lib/mysql \
-v /home/mysql/conf/my.cnf:/etc/mysql/my.cnf \
-e MYSQL_ROOT_PASSWORD=Ykm \
-d mysql

不过上面的-e MYSQL_ROOT_PASSWORD=Ykm \似乎没用

进入容器创建远程连接

docker exec -it 容器ID或名称 bash

docker exec -it mysql /bin/bash
mysql -u root -p
可能输入密码也进不去

也许可以直接使用无密码模式可以进入

mysql -u root

创建一个新账号用于远程连接

CREATE USER 'admin'@'%' IDENTIFIED BY 'tyuueew33IIIOOO88qqq';

赋予权限

GRANT ALL ON *.* TO 'admin'@'%';

FLUSH PRIVILEGES;

断开navicat并重新连接

创建数据库

可以使用navicat图形化界面创建

docker启动失败

docker logs 

报错,以下报错显示没有权限,原因是my.cnf需要增加一行

#不检查赋值目录
secure_file_priv=

[root@izwz99kdj07ayo2p6q5ntdz ~]# docker logs aa7f59febb86
2025-04-05 05:44:32+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
2025-04-05 05:44:32+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-05 05:44:32+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
2025-04-05 05:44:32+00:00 [Note] [Entrypoint]: Initializing database files
2025-04-05T05:44:32.848501Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.27) initializing of server in progress as process 42
2025-04-05T05:44:32.860756Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-04-05T05:44:34.426855Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-04-05T05:44:35.789846Z 0 [Warning] [MY-010161] [Server] You need to use --log-bin to make --binlog-expire-logs-seconds work.
2025-04-05T05:44:36.120842Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-04-05T05:44:36.120878Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-04-05T05:44:36.176636Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2025-04-05 05:44:40+00:00 [Note] [Entrypoint]: Database files initialized
2025-04-05 05:44:40+00:00 [Note] [Entrypoint]: Starting temporary server
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2025-04-05T05:44:40.866038Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2025-04-05 05:44:40+00:00 [ERROR] [Entrypoint]: Unable to start server.
2025-04-05 05:44:41+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
2025-04-05 05:44:41+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-05 05:44:41+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2025-04-05T05:44:42.114884Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2025-04-05T05:44:42.114931Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-04-05 05:44:42+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
2025-04-05 05:44:42+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-05 05:44:42+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2025-04-05T05:44:43.422624Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2025-04-05T05:44:43.422667Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-04-05 05:44:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
2025-04-05 05:44:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-05 05:44:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2025-04-05T05:44:44.921504Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2025-04-05T05:44:44.921553Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-04-05 05:44:46+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
2025-04-05 05:44:46+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-05 05:44:46+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2025-04-05T05:44:46.785147Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2025-04-05T05:44:46.785198Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-04-05 05:44:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
2025-04-05 05:44:48+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-05 05:44:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2025-04-05T05:44:49.483939Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2025-04-05T05:44:49.483989Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-04-05 05:44:53+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
2025-04-05 05:44:53+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-04-05 05:44:53+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
2025-04-05T05:44:53.743940Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
2025-04-05T05:44:53.743989Z 0 [ERROR] [MY-010119] [Server] Aborting
[root@izwz99kdj07ayo2p6q5ntdz ~]#  Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
-bash: Failed: command not found

<think>我们正在讨论MySQL安装包文件名中的"el7"含义。用户提供了一个具体的文件名示例:mysql-8.0.27-el7-x86_64.tar,并询问其中"el7"的含义。 根据常见的Linux发行版命名规则: - "el" 是 "Enterprise Linux" 的缩写。 - "el7" 特指针对 Red Hat Enterprise Linux 7(RHEL 7)及其兼容发行版(如CentOS 7)编译的软件包。 因此,mysql-8.0.27-el7-x86_64.tar 这个包是为 RHEL 7 或 CentOS 7 系统编译的。 在文件名中: - mysql-8.0.27: MySQL版本- el7: 目标系统为RHEL 7或兼容系统 - x86_64: 64位x86架构 注意:这个命名规则也适用于其他使用RPM包管理器的系统,但主要针对RHEL及其衍生版。 引用[1]中提到了在CentOS 7(el7)上安装MySQL 5.7.31的步骤,使用的就是el7的包[^1]。 引用[2]同样是在CentOS 7上安装MySQL 5.6.48,也是el7的包[^2]。 引用[4]中安装的MySQL 5.7.19也是el7的包[^4]。 引用[5]中安装的是mysql-8.0.19-el7-x86_64,同样针对el7[^5]。 所以,结论是:el7表示该软件包是为RHEL 7及其兼容系统(如CentOS 7)设计的。 但是,需要注意的是,如果用户使用的不是RHEL或CentOS,而是其他Linux发行版(如Debian、Ubuntu或麒麟),则可能不兼容,因为不同发行版的库版本和依赖管理不同。 例如,在银河麒麟V10(基于Debian)上安装el7的包可能会遇到依赖问题,因为麒麟V10的库版本可能与RHEL7不一致。 因此,在选择安装包时,应确保与操作系统兼容。 相关问题: 1. 如何检查我的Linux系统是el7还是el8? 2. 在非RHEL系统上安装el7的MySQL包有哪些风险? 3. MySQL的el7和el8包有什么区别? 4. 如何为Ubuntu系统下载合适的MySQL安装包?</think>在 MySQL 安装包文件名中,**"el7"** 表示该软件包专门为 **Red Hat Enterprise Linux 7(RHEL 7)及其兼容系统** 编译构建。以下是详细解析: ### 🔍 "el7" 的具体含义 1. **"el" = Enterprise Linux** 指 Red Hat 企业级 Linux 及其完全兼容的衍生版(如 CentOS、Oracle Linux)。 2. **"7" = 主版本号** 特指 RHEL 7.x 系列操作系统(如 CentOS 7),其核心特征包括: - 内核版本:`3.10.x` - 核心库版本:`glibc 2.17` - 包管理器:`rpm/yum` - 初始化系统:`systemd` ### 📦 文件名结构解析(以示例为例) `mysql-8.0.27-el7-x86_64.tar` | 组件 | 含义 | |------|------| | `mysql-8.0.27` | MySQL 软件版本 | | **`el7`** | **目标系统:RHEL/CentOS 7** | | `x86_64` | CPU 架构(64位) | | `tar` | 打包格式 | ### ⚠️ 兼容性注意事项 1. **非 RHEL 系系统的风险** 在 Debian/Ubuntu 系(如银河麒麟 V10)直接安装 `el7` 包会导致: ```bash # 典型错误示例 error: Failed dependencies: libc.so.6(GLIBC_2.17)(64bit) is needed # 库版本不匹配[^1][^3] systemd is needed # 初始化系统差异 ``` 2. **版本锁定机制** `el7` 包依赖特定基础库版本,例如: ```bash $ rpm -qpR mysql-8.0.27-el7.rpm | grep glibc libc.so.6()(64bit) libc.so.6(GLIBC_2.14)(64bit) libc.so.6(GLIBC_2.17)(64bit) # 严格依赖 RHEL7 的 glibc 版本[^1][^4] ``` ### ✅ 最佳实践建议 1. **系统匹配原则** | 您的系统 | 应选安装包标记 | |----------|----------------| | RHEL/CentOS 7 | `el7` | | RHEL/CentOS 8 | `el8` | | Debian/Ubuntu | `.deb` 包 | | 银河麒麟 V10 | 麒麟专用包或 Docker 容器[^5] | 2. **验证系统版本** ```bash # 检查是否为 el7 兼容系统 $ cat /etc/redhat-release # CentOS 7 显示 "CentOS Linux release 7.x" $ uname -r # 内核需含 ".el7" 如 3.10.0-1160.el7.x86_64 ``` > 📌 **关键结论**:`el7` 是 **RHEL/CentOS 7 专用标识**,非此系列系统需避免使用,否则将引发库依赖冲突[^1][^3][^4]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

i7i8i9com

大家共赴星际梦想

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值