MySQL5.7–initialize specified but the data directory has files in it. Aborting.の対処法

MariaDBを削除してMySQL5.7をインストールして起動しようとしたらエラーとなりました。その時の対処法となります

環境

  • OS:CentOS7
  • DB:MySQL5.7

エラー文

 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
 [ERROR] --initialize specified but the data directory has files in it. Aborting.
 [ERROR] Aborting

とでてきます。

対処法

対処法としては以下のサイトがでてきたりします

このようにあります。

/var/lib/mysql/ が残っていませんか?

検証してみた結果、/var/lib/にmysql/ が残っているとこうなるとわかりました。

[root@mysql ~]# rm -rf /var/lib/mysql
[root@mysql ~]# ls /var/lib/
alternatives  chrony  dhclient  games   initramfs  machines  mlocate      mysql-keyring   os-prober  polkit-1  rpcbind  rpm-state  samba      systemd  tuned    yum
authconfig    dbus    fprint    hyperv  logrotate  misc      mysql-files  NetworkManager  plymouth   postfix   rpm      rsyslog    stateless  tpm      waagent

[root@mysql ~]# systemctl start mysqld.service

で問題無く起動しました。もし似たような方いたら一度消してみてください。

YouTube

YouTubeにもアップしました。

個人支援・寄付について

サイトラボではBuildreeの開発などのため、現在個人支援・寄付を受けております。ご協力いただける方はお願いいたします。当サイトではビットコインで受け付けております。

  • ビットコイン:3LHnADwZwUbic2L45EnVJEykiG6KfbqrwS