Running MySQL in Docker and persisting data to my created directory [duplicate]
P粉482108310
P粉482108310 2023-07-24 23:47:05
0
1
434
<p>I'm trying to run MySQL in Docker and persist the data to a directory I created. </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>Containers are started and stopped. In the container log I can see: </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>When I run the container without persisting data to the directory I created, it works fine. </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>How do I run MySQL in Docker and persist the data to a directory I create? </p>
P粉482108310
P粉482108310

reply all(1)
P粉025632437

Make sure that the directory you create is owned by the mysql user

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!