Install MySQL on MAC

Sep 2, 2018 2 min read
Install MySQL on MAC

Introduction

We'll install MySQL using Homebrew, so I'll assume that you have it installed, if not, please do so, here is the official page

Keep in mind that version 8.0 is not compatible with Node.js Auth, if that is your aim, you need another method of installation. Please go here.

Install

Depending on your needs, you may want to install more or less. In my case, I'll install also the workbench to administrate my DB, if you have another app, you can skip this one.

MySQL Server

Go to the official page and select macOS as your Operating System, and select the latest version  and choose the download type, my preference is DMG Archive. Go ahead and install it and remember to copy the password they will give you on the install.

MySQL Shell

To be able to interact with MySQL Server, we are going to install it's Shell. You can download it from here , for this one you don't need a specific version. Download it and install it.

MySQL Workbench

To administrate our DataBases we'll use the MySQL Workbench, you can get it from here.

Now that all that is installed, if you go to your terminal and you try to do something like mysql -u root -p it's not going to work. So you have two options:

  1. You can either go directly to the path like this: /usr/local/mysql/bin/mysql -u root -p so you can enter on your MySQL monitor, but once you close the terminal you'll have to type all that again. A better solution is to export the path to be able to use the mysql command alone, this is how you export it:
  2. There is a file in your root directory (to go to the root just type: cd ~ and hit enter) that is called .bash_profile and it's hidden, you need to open it and add a line. To open it, type: sudo vim .bash_profile and add the following: export PATH=/usr/local/mysql/bin:$PATH (if you are not familiar with vim, search for it's commands) now save and close and type sudo vim .bashrc to open the .bashrc file. Add the following line: export PATH=/usr/local/mysql/bin:$PATH

Now that you have exported the paths, reload your profile by typing: . ~/.bash_profile

Close your terminal and reopen it. Everything should be setup at this point so type: mysql -u root -p to access to MySQL monitor and you should get a screen like this:

The next step is to change the root password. Remember when I told you to save it during the installation?

Once you are inside the MySQL monitor like the image above, type: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; that will change the temporary password to one of your choice.

That is all, I hope it was helpful and hopefully we can focus on producing and not debugging things like this. Best.

Great! Next, complete checkout for full access to ArturoFM.
Welcome back! You've successfully signed in.
You've successfully subscribed to ArturoFM.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.