简体   繁体   中英

How to resolve --initialize specified but the data directory has files in it. on laradock mysql container

I'm using laradock. when I use docker-compose up mysql I got this error.

mysql_1                | Initializing database
mysql_1                | 2018-04-22T10:41:01.362165Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
mysql_1                | 2018-04-22T10:41:01.362585Z 0 [ERROR] Aborting
mysql_1                |
laradock_mysql_1 exited with code 1

I tried to add this setting on laradock/mysql/Dockerfile like this

ARG MYSQL_VERSION=latest
FROM mysql:${MYSQL_VERSION}

LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"

#####################################
# Set Timezone
#####################################

ARG TZ=UTC
ENV TZ ${TZ}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN chown -R mysql:root /var/lib/mysql/

COPY my.cnf /etc/mysql/conf.d/my.cnf

CMD ["mysqld --ignore-db-dir=lost+found"]

EXPOSE 3306

but, I'm still getting above error. Do you have any idea on this solution?

Thanks,

I had a similar issue. In order to solve it, you have to

  1. go to C:\\Program Files\\MySQL\\MySQL Server 5.7
  2. you will find a folder named data . rename it into data1 .
  3. launch command prompt as an administrator.
  4. execute mysqld --initialize-insecure .
  5. go to the services in the control panel, stop all services related to MySql such as MySQL57 .
  6. Start MySQL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM