在Docker中运行MySQL,并将数据持久化到我的创建的目录中 [duplicate]
P粉482108310
P粉482108310 2023-07-24 23:47:05
0
1
477
<p>我正在尝试在Docker中运行MySQL,并将数据持久化到我创建的目录中。</p> <pre class="brush:php;toolbar:false;">docker run --name mysql-mac -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my_strong_password -d mysql:latest -v /Users/alexeyzhulin/Projects/data/mysql:/var/lib/mysql</pre> <p>容器启动并停止。在容器日志中,我可以看到:</p> <pre class="brush:php;toolbar:false;">2023-07-17 21:53:45 2023-07-17 16:53:45+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started. 2023-07-17 21:53:45 2023-07-17 16:53:45+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2023-07-17 21:53:45 2023-07-17 16:53:45+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started. 2023-07-17 21:53:45 2023-07-17 16:53:45+00:00 [Note] [Entrypoint]: Initializing database files 2023-07-17 21:53:45 2023-07-17T16:53:45.915750Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead. 2023-07-17 21:53:45 2023-07-17T16:53:45.915794Z 0 [ERROR] [MY-010083] [Server] --verbose is for use with --help; did you mean --log-error-verbosity? 2023-07-17 21:53:45 2023-07-17T16:53:45.915904Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.33) initializing of server in progress as process 80 2023-07-17 21:53:45 2023-07-17T16:53:45.921828Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2023-07-17 21:53:46 2023-07-17T16:53:46.234691Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2023-07-17 21:53:46 2023-07-17T16:53:46.768297Z 0 [ERROR] [MY-010147] [Server] Too many arguments (first extra is '/Users/alexeyzhulin/Projects/data/mysql:/var/lib/mysql'). 2023-07-17 21:53:46 2023-07-17T16:53:46.768321Z 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. 2023-07-17 21:53:46 2023-07-17T16:53:46.768325Z 0 [ERROR] [MY-010119] [Server] Aborting 2023-07-17 21:53:48 2023-07-17T16:53:48.204456Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.33) MySQL Community Server - GPL.</pre> <p>当我在不将数据持久化到我创建的目录中运行容器时,它可以正常工作。</p> <pre class="brush:php;toolbar:false;">docker run --name mysql-mac -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my_strong_password -d mysql:latest</pre> <p>如何在Docker中运行MySQL并将数据持久化到我创建的目录中?</p>
P粉482108310
P粉482108310

全部回复(1)
P粉025632437

确保您创建的目录已经属于mysql用户所有

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!