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/.
Double click the DMG archive to mount it. Double click the pkg file for MySQL. 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 /usr/local/mysql/support-files/mysql.server start
You can stop the server as follows:
sudo /usr/local/mysql/support-files/mysql.server stop
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';