3

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,

Masahiro Hanawa
  • 133
  • 1
  • 1
  • 13
  • 1
    Actually, adding `--ignore-db-dir` was a very good idea. There is just a tiny error in the CMD format. It should be: `CMD ["mysqld", "--ignore-db-dir=lost+found"]`. – Régis B. Dec 07 '20 at 15:33

1 Answers1

0

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
Abdulkarim Kanaan
  • 1,703
  • 4
  • 20
  • 32
  • I did a `reinstall all the services` from the WAMP tray ==> Tools and now it's running fine – KTM Oct 12 '20 at 07:36