Step 0 - Install
Homebrew is a package manager that simplifies all database installs and management on a Mac.
=> Learn more on how to install Homebrew
# This will precisely install MySQL version 5.6 brew install mysql56
brew services start mysql56
Time to create a symlink.
brew link --force firstname.lastname@example.org
If done correctly, terminal will tell you to run something like this.
NOTE!!!: Your path will likely be personalized for you. Do not blindly copy this.
echo 'export PATH="/email@example.com/bin:$PATH"' >> /Users/<my user name>/.bash_profile
Test that things are looking good.
brew install postgres
createuser -d -a -s -P postgres
brew services start postgresql
Install community-edition service.
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
Step 2 - Database management
Homebrew can download, install, and manage 3rd party libraries. Here are a few helpful commands for managing these locally-installed databases.
=> Install Homebrew Services to manage your databases.
If you see this error, it can either mean that there are permission issues or things that did not install correctly.
Learn to Read the Error Logs
I generally suggest we first look at the error logs and see if we can better understand the problem.
The error log can be found here:
nano /usr/local/var/mysql/[look for your username].err
Common MySQL Errors
I've seen a lot of errors in my lifetime, and when it comes to MySQL, here are a few more common ones.
If you can't make sense of the error log, then one option is to uninstall MySQL and re-install everything.
brew uninstall mysql # Clean things up brew cleanup --force # Remove any associated files or folders launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist # Remove any plists that might be lingering around rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist # Remove the MySQL folder with recursion and force sudo rm -rf /usr/local/var/mysql
brew install mysql # Check your installation ps aux | grep mysql # Initialize the MySQl daemon mysqld --initialize --explicit_defaults_for_timestamp # Start the MySQL server (don't use sudo) mysql.server start