Introduction
Download MySQL - Multi-user and accessible SQL server that packs the most advanced database technology that was designed for speed, scalability and reliability. MySQL.pkg contains our MySQL installer now owned by Oracle. 29 characters with a suffix of.pkg will be all you need to install MySQL Mac. Double click the installer. Install MySQL – community installer opens.
MySQL is an opensource, relational database management system. Its name is the combination of two words that are My + SQL where my is the name of co-founder Michael Widenius's daughter and SQL is the abbreviation of Structured Query Language.
MySQL is widely used as a database system in various well-known companies like Google and Facebook. In this tutorial, we will learn the installation process of MySQL server on MacOS.
Prerequisites
- MacOS
- Login as an administrator on terminal.
Installation
Following steps are used to install MySQL on MacOS.
1) Download the latest version
Download the latest version of MySQL community server that is 5.7.20 from its official website or simply copy and paste https://dev.mysql.com/downloads/file/?id=473576 into our browser search bar. The file will be downloaded in disk image format which is to be mounted first on our volumes directory.
2) Mount the disk image file
Hdiutil is used with the mount option to mount the disk image file on volumes directory of root.
3) Using Installer to Install MySQL package
The command installs MySQL community server to the root directory. During the installation process, it also sets the default password for root to access MySQL.
When we install MySQL on MacOS, a default username and password is created which is shown to the user at the time of installation.
4) Unmount the Disk Image File
The MySQL package mounted on volumes directory needs to be unmounted. Hdiutil is used with the unmount option to do so.
5) Starting MySQL
On MacOS, all the support files are located at /usr/local/MySQL. Support-Files contains MySQL.server which is actually started when we need to access our database. We must have the path information of MySQL server in order to start MySQL. We must have super user permissions to start and stop MySQL database.
6) Working on MySQL Command Line
1. Accessing from command line
To run MySQL from command line, we need to start MySQL server first. Then, following command will be executed.
Where root is the username and password is r>mpyW,-J4xS .
2. Create database
To create database, we need to execute a SQL query which is as follows.
7) Stopping MySQL
To stop database, use the following command.
This should be really straightforward, but I found myself googling around. I wrote a recent post about how to create a web app with the Laravel PHP framework but connecting to the database was tricky.
First step, find out what version of OS X you are running. Click the apple icon in the top right corner of your screen and click “About This Mac”. I got something like this:
Next step, head over to the MySQL downloads page.
So with my computer I am running 10.11 and we want the .dmg file. Download Mac OS X 10.10 (x86, 64-bit), DMG Archive. Then you get to this lame screen:
MySQL is free and open source software (FOSS), you do not need to sign up or create an account. Click “No thanks, just start my download”. I let the download go directly to my “Downloads” folder when prompted, though you could place it anywhere. The download will take some time because it is 350mb, go get a coffee. Once the download is complete. Double click the file and a screen like this will open
Install Mysql In Mac
![Mysql for mac Mysql for mac](/uploads/1/2/9/3/129318818/838682351.png)
Double click it and go through the install process.
When I did it I got an alert box:
Add to path. This went in ~/**.zshrc **because I am using ZSH. If you are using bash for terminal (the default on OS X) this will be the ~/.bashrc file or ~/.bash_profile. This post explains the difference between the two files.
Add the mysql download to your path so that you can use the “mysql” command from the command line.
Then test it out:
Now that we have MySQL installed and accessible from the Terminal, it’s time to connect to the database and start the MySQL server. Let’s log in as root user (root@localhost) and use that funky password that popped up in the alert window after our install. In the above case it’s
#fW&tYe?<8?w
Great! Now we can create databases and run SQL queries right from the command line. That’s an awesome start, but there’s no way anyone is going to remember that password, nor is it enjoyable to type in every time we want to run MySQL. The full docs on changing passwords are here. For OSX you can run the command:
The
PASSWORD('root')
sets my password to “root”. Easy to remember right? You can set your password to anything you like, such as PASSWORD('myN3wp@Ssw0rd')
.Mysql Installer Download 64 Bit
To stop the server in the terminal run
control + D
. Congratulations! You’ve installed MySQL on OSX, made it accessible from the command line and updated your password for the root user.To start setting up a Laravel application and connect to a database using Sequel Pro you can follow my next tutorial:
Thanks for reading!
Update (9/16/17): Expired passwords
When trying to login to MySQL on OSX recently I ran into the following error:
![Mysql Mysql](/uploads/1/2/9/3/129318818/138670294.png)
There are a lot of StackOverflow threads and articles about this, many require writing SQL commands, though that was difficult for me without access to the terminal. In order to alleiviate this I found this SO answer that saved me:
Update 03/29/18:
Mysql Download Mac
- Helpful steps for Install MySQL on macOS Sierra as a gist link.
Update 05/14/19:
- I recently ran into an error when trying to fire up the MySQL shell:
Mysql Download Mac Os
I found the solution in this homebrew issue. Create an empty directory for this path:
mkdir /usr/local/etc/my.cnf.d