MySQL: initialize the Data Directory (--data-dir) for Operating System user other than mysql
From the website here, you can just modify this line

shell&gt; bin/mysqld --initialize --user=mysql


and change it to:

shell&gt; bin/mysqld --initialize --user=other_username


This user (who is NOT a user in the database server sense, but rather in the Operating System (OS) sense) only determines permissions on the underlying file system - i.e. who owns the data-dir for example, it has nothing to do with MySQL database users. For clarity, I would use different names for OS users and MySQL users.

With compilation of the source, you get even more fine-grained control over your system, but if all you want is to change the owner of the files on the underlying OS file system, then do it this way! 

You can use --initialize-insecure and then login as root and change the password straight away, logging in as root with no password:

shell &gt;mysql --user=root


and then

mysql&gt; ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
mysql&gt; flush privileges;


Logout and then login with 

shell &gt;mysql -u root -p


After -p type nothing else and press Return. You should then be prompted for the password (MyNewPass) that you have just entered.