在Docker中執行MySQL,並將資料持久化到我的建立的目錄中 [duplicate]
P粉482108310
P粉482108310 2023-07-24 23:47:05
0
1
516
<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' will deprecated and in mo reved and in will 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 meanlog --log- error-verbosity? 2023-07-17 21:53:45 2023-07-17T16:53:45.915904Z 0 [System] [MY-013169] [Server] /usr/sbin/my5d (mysqld 8.0.333) inservers inservers inservers ing裡 proas 533333335 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 MY-010147] [Server] Too many arguments (first 5ptra is '/Users/Projects/hulins/Projects/my/B5tra is '/Users/ :/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 unable. 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 (3my) - 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用戶所有

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板