[Solved] Mac Install mongodb error: NonExistentPath: Data directory /data/db not found.

Error Messages:

{“t”:{“$date”:“2021-11-10T08:18:57.122+08:00”},“s”:“E”, “c”:“CONTROL”, “id”:20557, “ctx”:“initandlisten”,“msg”:“DBException in initAndListen, terminating”,“attr”:{“error”:“NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the –dbpath command line option, or (2) by adding the ‘storage.dbPath’ option in the configuration file.”}}
NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file.
This error means: The /data/db directory is not found. Let us use –dbpath to specify the directory to start or add storage.dbPath to specify the directory

Use --dbpath to Startup

Read More: