[MY-010457]、 [MY-013236]错误 Docker安装MySqL初始化错误解决办法错误出现创建语句分析查找问题分析问题 --initialize --lower-case-table-names=1 惹的祸不同系统,
-v /home/data/Mysqlyx/conf/my.cnf:/etc/mysql/my.cnf
以上为干货,直接解决问题,以下为原因分析及解决过程,希望对大家理解问题及解决问题有帮助。
#以mysqlyx为容器名示例进行说明docker logs --tail 50 --follow --timestamps mysqlyx#后面出现类似如下的错误: 2022-09-14T07:09:39.806206263Z 2022-09-14 07:09:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.2022-09-14T07:09:39.942722466Z 2022-09-14 07:09:39+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'2022-09-14T07:09:39.956643812Z 2022-09-14 07:09:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.2022-09-14T07:09:40.100100257Z 2022-09-14 07:09:40+00:00 [Note] [Entrypoint]: Initializing database files2022-09-14T07:09:40.125093527Z 2022-09-14T07:09:40.118405Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.27) initializing of server in progress as process 432022-09-14T07:09:40.129628141Z 2022-09-14T07:09:40.129522Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.2022-09-14T07:09:41.114997148Z 2022-09-14T07:09:41.114854Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.2022-09-14T07:09:43.132741452Z 2022-09-14T07:09:43.132579Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main2022-09-14T07:09:43.132774092Z 2022-09-14T07:09:43.132604Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main2022-09-14T07:09:43.352238721Z 2022-09-14T07:09:43.352109Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty passWord ! Please consider switching off the --initialize-insecure option.2022-09-14T07:09:47.267751506Z 2022-09-14 07:09:47+00:00 [Note] [Entrypoint]: Database files initialized2022-09-14T07:09:47.271081676Z 2022-09-14 07:09:47+00:00 [Note] [Entrypoint]: Starting temporary server2022-09-14T07:09:47.300216889Z 2022-09-14T07:09:47.297151Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.27) initializing of server in progress as process 922022-09-14T07:09:47.300230820Z 2022-09-14T07:09:47.300062Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.2022-09-14T07:09:47.300238120Z 2022-09-14T07:09:47.300080Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.2022-09-14T07:09:47.305642452Z 2022-09-14 07:09:47+00:00 [ERROR] [Entrypoint]: Unable to start server.2022-09-14T07:12:30.351300702Z 2022-09-14 07:12:30+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.2022-09-14T07:12:30.377699965Z 2022-09-14 07:12:30+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config2022-09-14T07:12:30.377731662Z command was: mysqld --initialize --lower-case-table-names=1 --verbose --help --log-bin-index=/tmp/tmp.Aeh6i8SECV2022-09-14T07:12:30.377738666Z 2022-09-14T07:12:30.368865Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.27) initializing of server in progress as process 102022-09-14T07:12:30.377744704Z 2022-09-14T07:12:30.370835Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.2022-09-14T07:12:30.377750404Z 2022-09-14T07:12:30.370847Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.2022-09-14T07:12:30.377770391Z 2022-09-14T07:12:30.372871Z 0 [ERROR] [MY-010119] [Server] Aborting
#/home/data/为本地卷,非容器的docker run --name mysqlyx -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=rootmysql \-v /home/data/mysqlyx/conf/my.cnf:/etc/mysql/my.cnf \-v /home/data/mysqlyx/data:/var/lib/mysql \-v /home/data/mysqlyx/log:/var/log/mysql \ mysqlyx --initialize --lower-case-table-names=1
网上查了很多办法,给出如下1-5的方法都没法解决本人的问题。
尝试一些创建语句进行,通过逐步加载容器创建参数来查找和定位问题,究竟哪个窗口创建参数的加入会出现问题,步骤如下:
#先运行基本的创建容器语句,下面语句成功运行,docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysqlyx#删除容器,然后再加挂载目录的参数(-v 的后面:左为主机目录或文件,右边为容器目录或文件)docker run --name mysqlyx -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=rootmysql \-v /home/data/mysqlyx/conf/my.cnf:/etc/mysql/my.cnf \-v /home/data/mysqlyx/data:/var/lib/mysql \-v /home/data/mysqlyx/log:/var/log/mysql \ mysqlyx #上面依然成功,然后再加参数:--initialize --lower-case-table-names=1 docker run --name mysqlyx -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=rootmysql \-v /home/data/mysqlyx/conf/my.cnf:/etc/mysql/my.cnf \-v /home/data/mysqlyx/data:/var/lib/mysql \-v /home/data/mysqlyx/log:/var/log/mysql \ mysqlyx --initialize --lower-case-table-names=1 #发现只要加入 --initialize --lower-case-table-names=1出现上述错误
lower_case_table_names = 1 表名存储在磁盘是小写的,但是比较的时候是不区分大小写
lower_case_table_names=0 表名存储为给定的大小写和比较是区分大小写的
lower_case_table_names=2, 表名存储为给定的大小写但是比较的时候是小写的
官方给出了回答
翻看Mysql官网,https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_lower_case_table_names
有这个一段说明:
lower_case_table_names can only be configured when initializing the server. Changing the lower_case_table_names setting after the server is initialized is prohibited.
也就是说如果想修改这个属性,必须在初始化数据库的时候就要指定该参数。
通常我们下载的docker mysql 镜像启动时会默认初始化,因此想要修改该参数就要重新初始化docker中的数据库。
只有在初始化的时候设置 lower_case_table_names=1才有效,比如:
–initialize --lower-case-table-names=1
vi /home/data/mysqlyx/conf/my.cnf# Custom config should Go here!includedir /etc/mysql/conf.d/lower_case_table_names = 1 #my.cnf这个文件怎么来的?有以下3种方式:1之前运行好的数据库里拷贝过来2 默认启动好的容器里直拷贝过来:docker cp mysql:/etc/mysql/my.cnf /home/data/mysqlyx/conf/3直接写一下
# 前面为本地目录文件路径,后面为容器文件及路径-v /home/data/mysqlyx/conf/my.cnf:/etc/mysql/my.cnf
来源地址:https://blog.csdn.net/jiguang127/article/details/126864288
--结束END--
本文标题: Docker 安装MySQL出现:The designated data directory /var/lib/mysql/ is unusable.错误解决办法
本文链接: https://lsjlt.com/news/372211.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0