Installing MySQL on OS X El Capitan

The steps below can be taken to install the MySQL relational database management system software on an Apple OS X/macOS system. The steps were taken for MySQL version 5.7.17 on a MacBook Pro laptop running OS X El Capitan, but should be similar, if not exactly the same for other versions of MySQL and on other versions of OS X.
  1. An Apple Disk Image .dmg file can be downloaded from MySQL Downloads. You will see buttons to "Login using my Oracle Web account" or to "Sign Up for an Oracle Web account", but you don't need an account to download the file. You can simply click on the "No thanks, just start my download" link, instead.
  2. Double-click on the downloaded .dmg file, e.g. mysql-5.7.17-macos10.12-x86_64.dmg, which will open a window showing a .pkg file.

    MySQL .pkg file

  3. Double-click on the .pkg file within that window, you will then see the "welcome" window where you can click on the Continue button to proceed with installation of MySQL.

    MySQL welcome screen

  4. At the next screen, you will be asked to accept the software license agreement, which is the GNU General Public License (GPL) Version 2 license.

    MySQL software license agreement

    Click on Continue to proceed.

  5. At the next screen you will be informed how much disk space is required by the software, which was 1.13 GB for version 5.7.17 on my laptop. If you click on the Install button, a standard installation will occur that makes the software available to all users of the computer. You have the option to change the installation location at this screen.

    MySQL standard installation

    If you click on the Customize button, instead, you can deselect options By default, MySQL Test, which is a Test package having the test binaries, will not be installed.

    MySQL customized installation

    The following options are selected to be installed as part of the standard installation, but can be deselected at this screen.

    MySQL Server The MySQL Server software and associated utiities
    Preference Pane A preference pane that can start and stop the MySQL server
    Launchd Start the MySQL server via launchd and enable automatic start on boot
  6. If you are installing in the standard location, you will be prompted to supply a username and password for an account with administrator credentials. Provide those and click on Install Software.

    MySQL installation username and password

  7. At the conclusion of the installation, you will see a window that provides a temporary root password for using MySQL.

    MySQL root password

    Click on the OK button after you have written down the password.

  8. After you click on OK to acknowledge you've noted the password, you should see a screen informing you thta "The installation was completed successfully." You can click on the Close button at that screen to complete the installation process.

    MySQL installation completed

  9. You can close the window that shows the .pkg package file within it.

The MySQL software is now installed, but not started. You can start the software through the MySQL icon you should see within System Preferences, which you can reach by clicking on the Apple icon at the upper, left-hand corner of the screen.

System Preferences - MySQL

Note: The MySQL preference pane only starts and stops MySQL when the software has been been installed in the default location. Alternatively, though, if you installed Launchd Support, which is installed by default, you can start and stop the software by opening a Terminal window, i.e., a shell prompt, and using the instructions at Installing a MySQL Launch Daemon.

When you click on MySQL, You will then see a window displaying the MySQL Server Status. If you wish to have the MySQL Server automatically start when the system boots, leave the check box next to "Automatically Start MySQL Server on Startup" checked. You can start the software by clicking on the Start MySQL Server button.

MySQL Server Status

You will be prompted to provide a username and password for an account with administrator privileges on the system. When you provide those, you should see the status change to "running" and the button change to Stop MySQL Server.

MySQL Server running

You can close the MySQL window once you have started the software. You can verify the software is working by issuing the following command at a Terminal window:

$ /usr/local/mysql/bin/mysql --version
/usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.7.17, for macos10.12 (x86_64) using  EditLine wrapper
$

If you wish to change the MySQL root password, which isn't the same as the system's root account password, to something you can more easily remember, you can do so using the mysqladmin command as shown below. You will first be prompted to provide the current password. When you provide that password, you will be prompted for the new password and then asked to retype the new password to ensure you have not mistyped it, since the password is not echoed back to you as you type it.

$ /usr/local/mysql/bin/mysqladmin -u root -p password
Enter password: 
New password: 
Confirm new password: 
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
$

The warning let's you know that if you are using accessing the server remotely, you may potentially expose the password to others snooping on network traffic, if you provide the password over an unencrypted connection.

You can obtain a MySQL command prompt using the root MySQL account and the password provided earlier by issuing the command below:

$ /usr/local/mysql/bin/mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 130
Server version: 5.7.17

Copyright (c) 2000, 2016, 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

You can type exit to return to the Bash shell prompt.