Bug #92370 mysqld --initialize fails because data directory has files in it
Submitted: 11 Sep 2018 20:21 Modified: 12 Sep 2018 0:45
Reporter: Tony Darnell Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:8.0.12 OS:MacOS (10.13.2)
Assigned to: CPU Architecture:x86 (64-bit)

[11 Sep 2018 20:21] Tony Darnell
After a fresh installation of MySQL 8.0.12 (package V979096-01) on Mac OS 10.13.2 (via DMG installer) and then running "mysqld --initialize", the process fails because the data directory has files in it.

[ Install MySQL 8.0.12 via DMG ] 

root # mysqld --initialize
2018-09-10T19:56:28.164742Z 0 [System] [MY-013169] [Server] /usr/local/mysql-commercial-8.0.12-macos10.13-x86_64/bin/mysqld (mysqld 8.0.12-commercial) initializing of server in progress as process 20179
2018-09-10T19:56:28.166871Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2018-09-10T19:56:28.166927Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-09-10T19:56:28.167143Z 0 [System] [MY-010910] [Server] /usr/local/mysql-commercial-8.0.12-macos10.13-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.12-commercial)  MySQL Enterprise Server - Commercial.

After removing the files in the data directory via "rm -R $MYSQL_HOME/data/*", two additional files appear.  Attempting "mysqld --initialize" fails again.

# root # pwd
root # rm -R data/*
root # mysqld --initialize
[ fails again ]

root # ls -l
total 8
-rw-r-----  1 _mysql  _mysql     0 Sep 10 15:56 mysql-bin.index
-rw-r-----  1 _mysql  _mysql  1468 Sep 10 15:57 mysqld.local.err

Removing the files from the data directory and running the "mysqld --initialize" immediately afterwards does work:

#  rm -R data/*; mysqld --initialize
[ success ]

However, the password entered via the DMG installation is no longer valid, so you have to look in the error log file for the new root password.

How to repeat:
Install MysQL via DMG, and run the "mysqld --initialize" command.

Suggested fix:
Fix the installer so the data directory is blank - or incorporate "mysqld --initialize" into the installer program.
[11 Sep 2018 23:26] MySQL Verification Team
Installer asking for root password so the data directory is created by installer during installing

Attachment: 01_creating_root_password.png (image/png, text), 450.47 KiB.

[11 Sep 2018 23:26] MySQL Verification Team
End install Success

Attachment: 02_end_install.png (image/png, text), 878.41 KiB.

[11 Sep 2018 23:27] MySQL Verification Team
Login after the install no need to use --initialize

Attachment: 03_login_to_the_server.png (image/png, text), 386.31 KiB.

[11 Sep 2018 23:31] MySQL Verification Team
Thank you for the bug report. Install on MAC OSX using the DMG installer package creates during the installation the data directory, please see the picture attached when asking for root password. Then isn't necessary to perform the initialize command and the error is correct the data directory has files which are the data initial stuff.
[12 Sep 2018 0:45] Tony Darnell
Thanks for the comments - I didn't realize the --initialize was unnecessary.