rancher2部署MySQL5.7,采用Longhorn无法做持久化怎么办?

使用rancherV2.5.7版本部署MySQL5.7,环境变量有添加MYSQL_ROOT_PASSWORD参数,存储使用的Longhorn,将MySQL的/var/lib/mysql目录挂载到服务器本地磁盘如/home/mysql/data,可以正常启动和使用。
但是当创建pvc挂载时,MySQL无法启动,报错日志如下:
2021-06-03 08:11:56+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
2021-06-03 08:11:56+00:00 [Note] [Entrypoint]: Switching to dedicated user ‘mysql’
2021-06-03 08:11:56+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
2021-06-03 08:11:56+00:00 [Note] [Entrypoint]: Initializing database files
2021-06-03T08:11:56.684273Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use —explicit_defaults_for_timestamp server option (see documentation for more details).
2021-06-03T08:11:56.686011Z 0 [ERROR] —initialize specified but the data directory has files in it. Aborting.
2021-06-03T08:11:56.686062Z 0 [ERROR] Aborting
加了MYSQL_ROOT_PASSWORD参数,去掉存储挂载配置,查看正常启动的容器/var/lib/mysql目录确实有数据,如果不加这个root密码相关的参数,MySQL又无法启动。
有哪位大佬遇到过么?求赐教

已邀请:

块存储 pv 创建好之后会在根目录下有个文件,但是 mysql 初始化的时候 data 目录是不能有任何文件的,所以报 initialize specified but the data directory has files in it. 



要回复问题请先登录注册