Tag Archives: [ERROR] initialize specified but the data directory has files in it. Aborting.

Docker Run MYSQL Container Error: [ERROR] –initialize specified but the data directory has files in it. Aborting.

background

Start the MySQL container by running the local MAC docker

docker run -d -p 3306:3306 --name mysql1 -v /Users/polo/data/conf:/etc/mysql/conf.d -v /Users/polo/data/mysql:/var/lib/mysql  -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

phenomenon

Check the container log and find that an error is reported, and the local Navicat cannot be connected

Root cause

Files already exist in the directory mounted through – V, so when – V selects the local directory, remember to select an empty directory/nonexistent directory (it will be created automatically)

Solution

Reference links for problem solving

Replace the -v mounted local directory with an empty directory/nonexistent directory

Start the log of MySQL container normally

No error log