MySQL is a fast, multi-threaded, multi-user open source SQL database server.

The MySQL database is released under the GNU General Public License (GPL). MySQL can be used for free when you are not distributing any part of the MySQL system. For example: If you run a commercial web site using the MySQL Database Software as long as MySQL is not distributed.

Please read the MySQL manual for situations where a commercial license is needed.

More information about MySQL can be found at:

MySQL online manual can be found at:

The latest MySQL version can be downloaded from:

Setup MySQL on macOS Sierra.


Operating system used
macOS Sierra

Software prerequisites
Apache in macOS Sierra with PHP, Server Side Includes and name-based virtual hosting

  1. Download and install the latest MySQL Community Server version.
    For example: MySQL Community Server 5.7.17 for Mac OS X 10.12 (x86, 64-bit), DMG Archive

  2. Once the installation has been completed successfully, you will be provided with your temporary root password. Save this temp password. We will change it!

  3. Modify your .bash_profile file, add the following line:
    export PATH=$PATH:/usr/local/mysql/bin

  4. To change the root password:
    • Stop MySQL Server, open a terminal and type:

      sudo /usr/local/mysql/support-files/mysql.server stop
      Enter your mac password

      You will see:

      Shutting down MySQL
      .. SUCCESS!

    • Set MySQL in safe mode, type:

      sudo mysqld_safe --skip-grant-tables
      Enter your mac password

      Leave this terminal open!

    • Open a new terminal and type:

      mysql -u root

      You will see:


    • Enter a new MySQL root password, for example: mysecret, type:

      ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysecret';

      Watch out for the single quotes used in root and localhost.

    • Start MySQL Server, open a terminal and type:

      sudo /usr/local/mysql/support-files/mysql.server start
      Enter your mac password

      You will see:

      Starting MySQL

      You can also start/stop MySQL server by GUI:
      - Select Mac System Preferences
      - Double click the MySQL icon

    • You can now close both terminals.

  5. To show your MySQL version, type:

    mysql -v -uroot -p
    Enter your mysql root password

    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 170
    Server version: 5.7.17 MySQL Community Server (GPL)

  6. Link MySQL socket, type:

    sudo mkdir /var/mysql
    sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

    MySQL create the socket in the /tmp folder
    MacOS expect the MySQL socket to be in folder /var/mysql

  7. Download the latest phpMyAdmin web application.
    For example: phpMyAdmin 4.7.0

    Download phpMyAdmin-4.7.0-english.tar.gz

  8. Unpack this file in folder: ~/Sites/

    After unpacking you will see: ~/Sites/phpmyadmin

  9. Open a browser and goto:

    For example:

    In my OSX Apache setup I have implemented a name based virtual hosting.
    See tutorial: Setup Apache in macOS Mojave with PHP, Server Side Includes and name-based virtual hosting

    File /usr/local/etc/httpd/extra/httpd-vhosts.conf contains:

    <VirtualHost *:80>
       DocumentRoot "/Users/robertlie/Sites/phpmyadmin"
       ErrorLog "/usr/local/var/log/httpd/phpmyadmin-error.log"
       CustomLog "/usr/local/var/log/httpd/phpmyadmin-access.log" common

    And file /etc/hosts file contains:

    #Local sites

    To access phpmyadmin:

  10. Select the Overview screen and press the "New Server" button.

  11. Select tab "Authentication"

  12. Enter in field "User for config auth": root
    Enter in field "Password for config auth": mysecret

    Press the Apply button

    Enter the MySQL root password you have set earlier.

  13. Go back to the Overview screen and press the "Download" button to download the configuration file

  14. Move the configuration file to: ~/Sites/phpmyadmin/

  15. Open a browser and goto:

    For example:

    Enter username: root
    Enter password: mysecret