Skip to content

Installing MySQL on a Mac

With newer versions of MySQL, it is becoming quite easy to install MySQL on Mac OS X.

The first step is to download the MySQL server. You can download the MySQL Community Server for free from dev.mysql.com. Typically there are several versions of the Community Server available, including the latest stable release, the lastest release candidate, and the latest Alpha or Beta release. In this example, we are going to proceed assuming the 5.7 version of Community Server.

Version 5.7 can be downloaded from this URL:

https://dev.mysql.com/downloads/mysql/5.7.html

You want to select the Mac OS X Package format as the download format. You do not need to login, simply look for the link that reads No thanks, just start my download.

This will download a .dmg file (Disk Image) to your machine. Double-clicking the disk image will show a window containing a mysql-*.pkg file. Double-clicking this .pkg file will launch the installer that will install MySQL on your system. If you would like for MySQL to start each time your system starts, you can also launch the MySQLStartupItem.pkg file contained in the disk image.

The installer installs MySQL in the /usr/local/mysql-version directory. It also creates a symboilic link in the /usr/local directory called mysql.

The new versions of MySQL generate a temporary password for the ‘root’ user. You will be prompted about this password during installation. Make sure you keep a note of this password as you will need it later.

You need to start the MySQL server. Go to System Preferences and open th MySQL icon. Once you are there click on the button that says Start MySQL Server. The window should toggle the status of the server to running.

To start MySQL, you can launch the Terminal application found in Applications/Utilities/Terminal. Once the terminal window appears, you can type the following:

> cd '/usr/local/mysql

Then type the following:

> ./bin/mysql -u root -p

Enter your password when prompted. At this point, MySQL should be running on your localhost (127.0.0.1) on port 3306.

You will need to change the temporary password by typing the following command in the mysql? prompt:

mysql> SET PASSWORD = PASSWORD('your_new_password');

The create user tool should generate SQL similar to the following:

mysql> create user 'USERNAME'@'localhost' identified by 'PASSWORD!';

Change

USERNAME

and

PASSWORD

to the appropriate values.

We can now create a test database:

CREATE DATABASE test;

and finally grant priviledged to your user:

GRANT ALL PRIVILEGES ON test.* TO 'USERNAME'@'localhost';

You can then log out and login with the USERNAME account.

Installing GUIs to manage your database

You can use a variety of GUIs to manage your databases. I recommend the following:

You can configure the connection using the credentials that you generated on the previous section.

You can now follow many tutorials available on line. For instance:

https://dev.mysql.com/doc/mysql-getting-started/en/

http://studybyyourself.com/seminar/sql/course/?lang=en

https://en.m.wikibooks.org/wiki/SQL_Exercises

https://www.w3schools.com/sql/default.asp

Et voilà!

Tags: