Installing and using MySQL in Mac OS X is a little different than the other Unix OS. In this article, I will list the basic steps.
Download and Install
First, download the DMG archive for Mac OS X from http://dev.mysql.com/downloads/mysql/. For example, the downloaded file will be mysql-5.7.9-osx10.10-x86_64.dmg.
Double click the DMG archive to mount it.
Double click the pkg file for MySQL, for example mysql-5.7.9-osx10.10-x86_64.pkg. This will launch the installer GUI. Complete the installation.
The installer will assign a random password for root. Copy the password.
Starting the Server
Start the server by running this command:
sudo launchctl start com.mysql.mysql
You can stop the server as follows:
sudo launchctl stop com.mysql.mysql
Starting the Client Tool
Make sure that the server is running. Run this command to launch the client tool:
/usr/local/mysql/bin/mysql -u root -p
This will connect to the server using the user id
root is a MySQL user and not the OS user. Enter the password generated by the installer.
Change Root Password
While connected to MySQL using the mysql client tool, enter this SQL statement:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'my_password';