Im going to install mysql to linux server. But I dont have root access to that server. So I created two folders called mysql and mysqldata. mysql folder holds binary files. mysqldata folder holds data and the logs.
[mysqld]
user = mysql
port = 3306
bind-address = localhost
basedir = /home/nwn/mysql/mysql-8.0
socket = /home/nwn/mysqldata/instA/socket/mysql.sock
datadir = /home/nwn/mysqldata/instA/data
tmpdir = /home/nwn/mysqldata/instA/tmp
secure_file_priv = /home/nwn/mysqldata/instA/mysql-files
max_connections = 150
# Logging
log-bin = /home/nwn/mysqldata/instA/logs/instA-binlog
log-error = /home/nwn/mysqldata/instA/logs/instA-errorlog.err
slow_query_log = 1
slow_query_log_file = /home/nwn/mysqldata/instA/logs/instA-slowquery.log
long_query_time = 0.5
# InnoDB
innodb_data_home_dir = /home/nwn/mysqldata/instA/innodb/data
innodb_data_file_path = ibdata1:50M;ibdata2:12M:autoextend:max:500M
innodb_log_group_home_dir = /home/nwn/mysqldata/instA/innodb/log
innodb_buffer_pool_size = 32M
# MyISAM
key_buffer_size = 16M
server_id = 1
I did all the other configurations. when I run following command
mysql-8.0]$ bin/mysqld --defaults-file=~/mysqldata/instA/my.cnf --initialize-insercure
I have following logs in the error_log
cat ~/mysqldata/instA/logs/instA-errorlog.err
2018-10-09T10:39:51.127424Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8160)
2018-10-09T10:39:51.127523Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 432 (requested 4000)
2018-10-09T10:39:51.383986Z 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
2018-10-09T10:39:51.384043Z 0 [System] [MY-010116] [Server] /home/nwn/mysql/mysql-8.0/bin/mysqld (mysqld 8.0.12) starting as process 32654
2018-10-09T10:39:51.386625Z 0 [Warning] [MY-010122] [Server] One can only use the --user switch if running as root
2018-10-09T10:39:51.394675Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2018-10-09T10:39:51.394817Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2018-10-09T10:39:51.394831Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-10-09T10:39:51.395363Z 0 [System] [MY-010910] [Server] /home/nwn/mysql/mysql-8.0/bin/mysqld: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.
Even though the post is very old, but posting my solution as it took me around 2 hours to figure it out and this can help someone save that time.
You can try doing :
shell> mysqld --initialize
This shall initialse the data directory in the path where you have installed MySql server. Generally placed at C:\Program Files\MySQL\MySQL Server 8.0.
Hope it helps someone.