title: mysql says root@localhost is created with an empty password ! But nothings happening. did I miss something?
body: <p>This started off as a root password resetting exercise- but been running into various errors: Currently stuck at conflicts on 3306 port. See last few paras of the question if you want to skip the previous steps (I just kept updating the question &amp; title as I made progress). Thank you.</p>
  
  <p>I have a mac with mysql installed- but I cant remember the password hence I've been trying to reset it using: <code>https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html</code> <code>(section:B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems)</code>. </p>
  
  <p>While running this command:
  <code>mysqld --init-file=/home/me/mysql-init &amp;</code></p>
  
  <p>I got this error:</p>
  
  <pre><code>`[1] 70374
  Deepaks-MacBook-Air:data root# 2018-05-06T08:35:29.269289Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2018-05-06T08:35:29.271535Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  2018-05-06T08:35:29.272815Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 70374 ...
  2018-05-06T08:35:29.290319Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
  2018-05-06T08:35:29.290429Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
  
  2018-05-06T08:35:29.290472Z 0 [ERROR] Aborting
  
  2018-05-06T08:35:29.290494Z 0 [Note] Binlog end
  2018-05-06T08:35:29.293896Z 0 [Note] mysqld: Shutdown complete
  
  [1]+  Done(1)`
  </code></pre>
  
  <p>Hence I'm trying this command: 
  <code>sudo /usr/local/mysql/support-files/mysql.server start --init-file=/usr/local/mysql/data/mysql-init</code></p>
  
  <p>but now I'm getting this error: 
  <code>ERROR! The server quit without updating PID file (/usr/local/mysql/data/Deepaks-MacBook-Air.local.pid).</code></p>
  
  <p>The following is the content of the log file:</p>
  
  <pre><code>2018-05-06T08:03:52.799002Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2018-05-06T08:03:52.801385Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  2018-05-06T08:03:52.801495Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.21) starting as process 69954 ...
  2018-05-06T08:03:52.810622Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
  2018-05-06T08:03:52.832273Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  2018-05-06T08:03:52.832306Z 0 [Note] InnoDB: Uses event mutexes
  2018-05-06T08:03:52.832313Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
  2018-05-06T08:03:52.832319Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
  2018-05-06T08:03:52.832780Z 0 [Note] InnoDB: Number of pools: 1
  2018-05-06T08:03:52.833783Z 0 [Note] InnoDB: Using CPU crc32 instructions
  2018-05-06T08:03:52.838027Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
  2018-05-06T08:03:52.856588Z 0 [Note] InnoDB: Completed initialization of buffer pool
  2018-05-06T08:03:52.876537Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
  2018-05-06T08:03:52.899436Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  2018-05-06T08:03:52.900043Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  2018-05-06T08:03:52.944160Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  2018-05-06T08:03:52.946174Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  2018-05-06T08:03:52.946218Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  2018-05-06T08:03:52.946641Z 0 [Note] InnoDB: Waiting for purge to start
  2018-05-06T08:03:53.001405Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 2551377
  2018-05-06T08:03:53.001712Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql-5.7.21-macos10.13-x86_64/data/ib_buffer_pool
  2018-05-06T08:03:53.001962Z 0 [Note] Plugin 'FEDERATED' is disabled.
  2018-05-06T08:03:53.019470Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
  2018-05-06T08:03:53.020660Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 13:33:53
  2018-05-06T08:03:53.026724Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
  2018-05-06T08:03:53.026844Z 0 [Note] IPv6 is available.
  2018-05-06T08:03:53.026872Z 0 [Note]   - '::' resolves to '::';
  2018-05-06T08:03:53.026926Z 0 [Note] Server socket created on IP: '::'.
  2018-05-06T08:03:53.087999Z 0 [Note] Event Scheduler: Loaded 0 events
  2018-05-06T08:03:53.088163Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
  Version: '5.7.21'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Server (GPL)
  2018-05-06T08:12:46.664218Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
  2018-05-06T09:35:55.013341Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 2948657ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
  </code></pre>
  
  <p>Whats wrong and how to fix this?</p>
  
  <p>PS: I've been referring to these two SO, and am trying nearly all solutions in all answers- reseting permissions to removing all files in <code>/usr/local/var/mysql</code>. It still the same issue, I suspect its something to do with mysqld not running properly- is there a special way to run it as root. I'm currently trying to run in root mode in terminal by <code>sudo -i</code>. Can someone help me debug this? Thanks</p>
  
  <p>mysql version:</p>
  
  <pre><code>&gt; mysql --version
  mysql  Ver 14.14 Distrib 5.7.21, for osx10.12 (x86_64) using  EditLine wrapper
  </code></pre>
  
  <p>UPDATE: I read the security documentation- apparently you aren't supposed to run it as root mode. So I logged out using <code>exit</code>. </p>
  
  <p>Now, I'm getting the following situation:</p>
  
  <pre><code>Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init &amp;
  [2] 72004
  Deepaks-MacBook-Air:mysql deepak$ mysqld: Can't change dir to '/usr/local/var/mysql/' (Errcode: 2 - No such file or directory)
  2018-05-06T10:59:48.877152Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2018-05-06T10:59:48.880902Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  2018-05-06T10:59:48.881775Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72004 ...
  2018-05-06T10:59:48.897332Z 0 [Warning] Can't create test file /usr/local/var/mysql/Deepaks-MacBook-Air.lower-test
  2018-05-06T10:59:48.897395Z 0 [Warning] Can't create test file /usr/local/var/mysql/Deepaks-MacBook-Air.lower-test
  2018-05-06T10:59:48.897593Z 0 [ERROR] failed to set datadir to /usr/local/var/mysql/
  2018-05-06T10:59:48.897607Z 0 [ERROR] Aborting
  
  2018-05-06T10:59:48.897624Z 0 [Note] Binlog end
  2018-05-06T10:59:48.899188Z 0 [Note] mysqld: Shutdown complete
  </code></pre>
  
  <p>which I suspect is due to the removal of my /usr/local/var/mysql directory as was suggested in one of the other answers. I'd deleted that using <code>rm -rf</code>. I made an new dir <code>mkdir mysql</code> in <code>var</code> and ran <code>mysqld --init-file=/usr/local/mysql/data/mysql-init &amp;</code>, and it initially gives me a pid but then the logs ask me if 3306 port is already occupied:</p>
  
  <pre><code>2018-05-06T11:04:14.215705Z 0 [Note] Plugin 'FEDERATED' is disabled.
  mysqld: Table 'mysql.plugin' doesn't exist
  2018-05-06T11:04:14.218651Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
  2018-05-06T11:04:14.225038Z 0 [Note] Salting uuid generator variables, current_pid: 72031, server_start_time: 1525604653, bytes_sent: 0, 
  2018-05-06T11:04:14.225601Z 0 [Note] Generated uuid: '36553708-511d-11e8-ba65-c83fe4b8ed7b', server_start_time: 1828179975261387404, bytes_sent: 140216128435712
  2018-05-06T11:04:14.225667Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 36553708-511d-11e8-ba65-c83fe4b8ed7b.
  2018-05-06T11:04:14.241961Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  2018-05-06T11:04:14.391057Z 0 [Note] Auto generated SSL certificates are placed in data directory.
  2018-05-06T11:04:14.391874Z 0 [Warning] CA certificate ca.pem is self signed.
  2018-05-06T11:04:14.490103Z 0 [Note] Auto generated RSA key files are placed in data directory.
  2018-05-06T11:04:14.499147Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
  2018-05-06T11:04:14.499239Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
  2018-05-06T11:04:14.499424Z 0 [Note] Server socket created on IP: '127.0.0.1'.
  2018-05-06T11:04:14.499495Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
  2018-05-06T11:04:14.499503Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
  2018-05-06T11:04:14.499536Z 0 [ERROR] Aborting
  </code></pre>
  
  <p>I actually have two folders in my <code>/usr/local/</code> -  <code>mysql</code> and <code>mysql-5.7.21-macos10.13-x86_64</code>. The whole process so far, I've been running in the 'mysql<code>folder and haven't really touched</code>mysql-5.7.21-macos10.13-x86_64`. They seem to have the same directory structure inside.</p>
  
  <p>Also when I do <code>ps aux | grep mysql</code>, I get three processes:</p>
  
  <pre><code>Deepaks-MacBook-Air:local deepak$ ps aux | grep mysql
  deepak           72071 100.0  0.0  2443044   1992 s002  S+    4:44PM   0:00.01 grep mysql
  _mysql           71985   0.0  0.2  2852472  13132   ??  Ss    4:25PM   0:00.66 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid --keyring-file-data=/usr/local/mysql/keyring/keyring --early-plugin-load=keyring_file=keyring_file.so
  root             71967   0.0  0.1  2460804   7992 s002  T     4:23PM   0:00.03 sudo mysqld --init-file=/usr/local/mysql/data/mysql-init
  </code></pre>
  
  <p>However, when I proceed to kill the second or the third one, they simply reappear when I do ps aux again. </p>
  
  <p>Also, I usually use a portforwarding to connect to a remote MySQL host. So, every once a while and in local scripts I run <code>"ssh -fNT -L 3307:localhost:3306 -i ~/key/deepak_ubuntu_16feb.pem ubuntu@ec2-AWS-HOS-TNA-ME.compute-1.amazonaws.com"</code></p>
  
  <p>Could this be a conflict?</p>
  
  <p>UPDATE:
  OK, I ignored the other directory and simply changed the port, that seemed to now avoid the conflict, but now has a different problem: mysql.sock.lock cant be accessed?</p>
  
  <pre><code>Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init --port=3308 &amp;
  [2] 72160
  Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T11:32:45.441642Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2018-05-06T11:32:45.443453Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  2018-05-06T11:32:45.444202Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72160 ...
  2018-05-06T11:32:45.463651Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
  2018-05-06T11:32:45.478310Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  2018-05-06T11:32:45.478366Z 0 [Note] InnoDB: Uses event mutexes
  2018-05-06T11:32:45.478375Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
  2018-05-06T11:32:45.478384Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
  2018-05-06T11:32:45.480830Z 0 [Note] InnoDB: Number of pools: 1
  2018-05-06T11:32:45.483263Z 0 [Note] InnoDB: Using CPU crc32 instructions
  2018-05-06T11:32:45.487576Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
  2018-05-06T11:32:45.507092Z 0 [Note] InnoDB: Completed initialization of buffer pool
  2018-05-06T11:32:45.538289Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
  2018-05-06T11:32:45.565701Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  2018-05-06T11:32:45.565987Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  2018-05-06T11:32:45.622322Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  2018-05-06T11:32:45.623627Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  2018-05-06T11:32:45.623652Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  2018-05-06T11:32:45.623974Z 0 [Note] InnoDB: Waiting for purge to start
  2018-05-06T11:32:45.678385Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 1209980
  2018-05-06T11:32:45.678936Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
  2018-05-06T11:32:45.680200Z 0 [Note] Plugin 'FEDERATED' is disabled.
  2018-05-06T11:32:45.680346Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 17:02:45
  mysqld: Table 'mysql.plugin' doesn't exist
  2018-05-06T11:32:45.680885Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
  2018-05-06T11:32:45.684081Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  2018-05-06T11:32:45.686185Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
  2018-05-06T11:32:45.686212Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
  2018-05-06T11:32:45.691365Z 0 [Warning] CA certificate ca.pem is self signed.
  2018-05-06T11:32:45.691562Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
  2018-05-06T11:32:45.693912Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3308
  2018-05-06T11:32:45.694589Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
  2018-05-06T11:32:45.694853Z 0 [Note] Server socket created on IP: '127.0.0.1'.
  2018-05-06T11:32:45.695047Z 0 [ERROR] Could not open unix socket lock file /tmp/mysql.sock.lock.
  2018-05-06T11:32:45.695067Z 0 [ERROR] Unable to setup unix socket lock file.
  2018-05-06T11:32:45.695092Z 0 [ERROR] Aborting
  </code></pre>
  
  <p>OK, so I went into <code>/tmp/</code> and tried to check permissions of the file- below are the results:</p>
  
  <pre><code>Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock.lock 
  16777220 3413029 -rw------- 1 _mysql wheel 0 6 "May  6 16:25:35 2018" "May  6 16:25:35 2018" "May  6 16:25:35 2018" "May  6 16:25:35 2018" 4096 8 0 mysql.sock.lock
  Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock
  16777220 3413030 srwxrwxrwx 1 _mysql wheel 0 0 "May  6 16:25:44 2018" "May  6 16:25:44 2018" "May  6 16:25:44 2018" "May  6 16:25:35 2018" 4096 0 0 mysql.sock
  </code></pre>
  
  <p>I'm trying the solutions from this SO post <code>https://stackoverflow.com/questions/34954455/mysql-daemon-lock-issue</code>, the change owner answer did not work. I'm a little hesitant to remove locking. </p>
  
  <p>OK, this post: <code>https://support.rackspace.com/how-to/checking-linux-file-permissions-with-ls/</code> quite neatly explains how to read those permissions- apparently in my case _mysql user and wheel are the owner and group respectively. That doesn't make sense because I've never come across <code>wheel</code> in anything out side a <code>.whl</code> context and I haven't encountered the _mysql before today. I've tried to change to that user earlier using <code>su - _mysql</code> and I couldn't guess the password- not sure if mysql sets this up by default, in which case I'm confused right about now.</p>
  
  <p>UPDATE:
  OK, I solved that my Chowning it:</p>
  
  <pre><code>Deepaks-MacBook-Air:tmp deepak$ sudo chown deepak mysql.sock
  Deepaks-MacBook-Air:tmp deepak$ sudo chown deepak mysql.sock.lock
  Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock.lock
  16777220 3413029 -rw------- 1 deepak wheel 0 6 "May  6 16:25:35 2018" "May  6 16:25:35 2018" "May  6 17:26:54 2018" "May  6 16:25:35 2018" 4096 8 0 mysql.sock.lock
  Deepaks-MacBook-Air:tmp deepak$ stat mysql.sock
  16777220 3413030 srwxrwxrwx 1 deepak wheel 0 0 "May  6 16:25:44 2018" "May  6 16:25:44 2018" "May  6 17:26:22 2018" "May  6 16:25:35 2018" 4096 0 0 mysql.sock
  </code></pre>
  
  <p>However, that gives rise to another error:
  <code>Can't open and lock privilege tables: Table 'mysql.user' doesn't exist</code>.</p>
  
  <pre><code>Deepaks-MacBook-Air:mysql deepak$ mysqld --init-file=/usr/local/mysql/data/mysql-init --port=3308 &amp;
  [2] 72244
  Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T11:57:33.454182Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2018-05-06T11:57:33.456455Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  2018-05-06T11:57:33.457505Z 0 [Note] mysqld (mysqld 5.7.21) starting as process 72244 ...
  2018-05-06T11:57:33.470925Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
  2018-05-06T11:57:33.482170Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  2018-05-06T11:57:33.482216Z 0 [Note] InnoDB: Uses event mutexes
  2018-05-06T11:57:33.482224Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
  2018-05-06T11:57:33.482231Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
  2018-05-06T11:57:33.486263Z 0 [Note] InnoDB: Number of pools: 1
  2018-05-06T11:57:33.489217Z 0 [Note] InnoDB: Using CPU crc32 instructions
  2018-05-06T11:57:33.494624Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
  2018-05-06T11:57:33.513877Z 0 [Note] InnoDB: Completed initialization of buffer pool
  2018-05-06T11:57:33.546517Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
  2018-05-06T11:57:33.575022Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  2018-05-06T11:57:33.575404Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  2018-05-06T11:57:33.620985Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  2018-05-06T11:57:33.622662Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  2018-05-06T11:57:33.622693Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  2018-05-06T11:57:33.623068Z 0 [Note] InnoDB: Waiting for purge to start
  2018-05-06T11:57:33.677963Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 1209999
  2018-05-06T11:57:33.679157Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
  2018-05-06T11:57:33.680426Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180506 17:27:33
  2018-05-06T11:57:33.681987Z 0 [Note] Plugin 'FEDERATED' is disabled.
  mysqld: Table 'mysql.plugin' doesn't exist
  2018-05-06T11:57:33.684004Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
  2018-05-06T11:57:33.688066Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  2018-05-06T11:57:33.690386Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
  2018-05-06T11:57:33.690502Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
  2018-05-06T11:57:33.694745Z 0 [Warning] CA certificate ca.pem is self signed.
  2018-05-06T11:57:33.694856Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
  2018-05-06T11:57:33.695461Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3308
  2018-05-06T11:57:33.696028Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
  2018-05-06T11:57:33.696184Z 0 [Note] Server socket created on IP: '127.0.0.1'.
  2018-05-06T11:57:33.700436Z 0 [Warning] Failed to open optimizer cost constant tables
  
  2018-05-06T11:57:33.704524Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
  
  2018-05-06T11:57:33.704983Z 0 [ERROR] Aborting
  </code></pre>
  
  <p>Alright, that got resolved by changing the owner from _mysql to my normal account using <code>chown</code> but now the the issue is:</p>
  
  <pre><code>Deepaks-MacBook-Air:mysql deepak$ mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --init-file=/usr/local/mysql/mysql-init --port=3308 &amp;
  [2] 72328
  Deepaks-MacBook-Air:mysql deepak$ 2018-05-06T12:21:01.547203Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2018-05-06T12:21:01.550869Z 0 [ERROR] Can't find error-message file '/usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
  2018-05-06T12:21:01.557694Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
  2018-05-06T12:21:01.557751Z 0 [ERROR] Aborting
  </code></pre>
  
  <p>Here is how I resolved this: the share folder didn't have a mysql directory and instead had the errmsg.sys in the english directory, I simply copied this file into a new directory I created in the share folder: <code>mkdir mysql</code>.</p>
  
  <p>This worked but then showed:</p>
  
  <pre><code>Can't create directory '/usr/local/mysql/data/' (Errcode: 13 - Permission denied)
  2018-05-06T12:49:13.313038Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2018-05-06T12:49:13.316262Z 0 [Warning] Using pre 5.5 semantics to load error messages from /usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/.
  2018-05-06T12:49:13.316285Z 0 [Warning] If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
  2018-05-06T12:49:13.322333Z 0 [ERROR] Aborting
  </code></pre>
  
  <p>Using chown, I changed the owner of mysql directory to my regular user account (strangely the mysql-5.7.21-macos10.13-x86_64 directory would not change its owner from group from root and wheel to anything even if I sudo'ed it. </p>
  
  <p>So now the <code>mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --init-file=/usr/local/mysql/mysql-init --port=3308 &amp;</code> command from <code>/usr/local/mysql/</code> shows the following output:</p>
  
  <pre><code>Deepaks-MacBook-Air:local deepak$ mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --init-file=/usr/local/mysql/mysql-init --port=3308 &amp;
  [2] 72460
  Deepaks-MacBook-Air:local deepak$ 2018-05-06T12:52:51.009693Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2018-05-06T12:52:51.013089Z 0 [Warning] Using pre 5.5 semantics to load error messages from /usr/local/mysql-5.7.21-macos10.13-x86_64/share/mysql/.
  2018-05-06T12:52:51.013108Z 0 [Warning] If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
  2018-05-06T12:52:51.020232Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
  2018-05-06T12:52:51.549560Z 0 [Warning] InnoDB: New log files created, LSN=45790
  2018-05-06T12:52:51.614133Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  2018-05-06T12:52:51.692927Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 630bcd34-512c-11e8-934a-45e8be00c2cf.
  2018-05-06T12:52:51.711501Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  2018-05-06T12:52:51.847929Z 0 [Warning] CA certificate ca.pem is self signed.
  2018-05-06T12:52:51.903182Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
  </code></pre>
  
  <p>This seemed good but nothing is happening. Is this it? Can I start connecting using my SequelPro to 'localhost:3308' now? or is there some other caveats I need to resolve like setting temp password? Before even that, do I need to go into another terminal window to try <code>mysql -u root</code> and leave this running or what? </p>
  
  <p>Also, when I don <code>ps aux | grep mysql</code> it shows three processes as before but does not show <code>72460</code> the one that mysqld just showed me now. Is this something I need to be concerned about?</p>
  
  <p>This is the first time I'm doing this, and I'm scared to do anything right about now to not ruin the last few hours of efforts to fix this.</p>
  
  <p>How do I resolve this? Thanks!</p>
  
  <p>UPDATE: FINAL ISSUES:</p>
  
  <p>OK, I'm dealing with a final set of issues, gonna ask in a seperate question.</p>
  
  <p>1)
      Deepaks-MacBook-Air:App deepak$ mysql -u root
      ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)</p>
  
  <p>and </p>
  
  <p>2)</p>
  
  <pre><code>Deepaks-MacBook-Air:App deepak$ mysqladmin -u root
  mysqladmin  Ver 8.42 Distrib 5.7.21, for osx10.12 on x86_64
  Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  
  Administration program for the mysqld daemon.
  Usage: mysqladmin [OPTIONS] command command....
  </code></pre>
  
  <p>3) In my System Preferences > MySQL, it says "<code>MySQL server instance is STOPPED</code>". </p>