Installing MySQL on Mac OS X

By: Colin Charles

http://techxplorer.com/2011/03/03/installing-mysql-on-mac-os-x/

 

To assist with my development work for and studies related to the Serval Project I need to install a local copy of the Ushahidi software.

The first step of this process is to install theMySQL database server software onto my laptop running Mac OS X. I used the MySQL Community Server version of the software.

Updates:

  • 04/03/2011 – add info on fixing the permission of the startup item and installing MySQL Workbench
  • 06/03/2011 – information on configuring MySQL Workbench is available via this post
  • 24/03/2011 – added note to step 7.13 & 7.16 regarding the use of single quotes

Step 0. Assumptions & Prerequisites

  1. You have a computer running the latest version of the Mac OS X operating system. At the time of writing this was version 10.6.6
    Other versions will likely work as well, I used this platform to write this guide
  2. You are comfortable using the command line interface provided by the Apple Terminal app
  3. You have a computer that has a 64 bit processor
    If you’re not sure consult this apple support document
    This procedure will likely work with a computer that has a 32 bit processor however the file names will be different.
    Read the MySQL download page carefully
  4. You know the hostname of your computer
    If you not sure follow the procedure in Appendix A
  5. You wish to install MySQL Community Sever version 5.5.9
    Other versions will likely work as well, especially the 5.5.x version, I used this version to write this guide
  6. No other version of MySQL has ever been installed on your computer

Step 1. Download the MySQL Software

  1. Go to the following website in your internet browser
    http://dev.mysql.com/downloads/mysql/5.5.html
  2. Scroll down the page a little way
  3. Ensure that Mac OS X is the selected option in the Select Platform drop down box
  4. Click the Download button to the right of the Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive option
  5. Click the No thanks, just take me to the downloads! link to skip the user registration prompt
  6. Click the HTTP or FTP link to the right of one of the automatically selected mirror sites
  7. Wait for the download to complete

Step 2. Install the MySQL Software

It is assumed that the file that was downloaded in step 1 was saved by your browser into the standard Downloads folder. If this is not the case use the folder specific to your system in step 2.1

  1. Open the downloads folder by clicking the downloads folder icon in your dock
  2. Double click the mysql-5.5.9-osx10.6-x86_64.dmg file
  3. Double click the drive icon labeled mysql-5.5.9-osx10.6-x86_64 that appears on your desktop
  4. Double click the mysql-5.5.9-osx10.6-x86_64.pkg icon
    The Install MySQL 5.5.9-community for Mac OSX window will appear
  5. Click the Continue button
  6. Peruse the Important Information
  7. Click the Continue button
  8. Peruse and understand the Software Licence Agreement
  9. Click the Continue button
  10. Click the Agree button to agree to the terms of the Software License Agreementdisplayed in step 2.8
  11. Click the Continue button
  12. Click the Install button
  13. Enter your password when prompted
  14. Click the Ok button
  15. Wait for the installation to finish
  16. Click the Close button

Step 3. Install the MySQL Startup Item

  1. Double click the drive icon labeled mysql-5.5.9-osx10.6-x86_64 on your desktop
  2. Double click the MySQLStartupItem.pkg file
    The Install MySQL Startup Item window will appear
  3. Click the Continue button
  4. Peruse the Important Information
  5. Click the Continue button
  6. Click the Continue button
  7. Click the Install button
  8. Enter your password when prompted
  9. Click the Ok Button
  10. Wait for the installation to finish
  11. Click the Close button
  12. Open a new Terminal window
  13. Ensure you are in your home directory by executing the following command
    cd ~
  14. Change the permissions on the file by executing the following command
    sudo chown -R root:wheel /Library/StartupItems/MySQLCOM
  15. Enter your password when prompted
  16. If you see an error
    Confirm that you entered the command exactly as shown
    Confirm that the MySQLCOM file exists at the path specified
    Consult the MySQL Reference Manual for further information
  17. Close the terminal window

Step 4. Install the MySQL Preference Pane

  1. Double click the drive icon labeled mysql-5.5.9-osx10.6-x86_64 on your desktop
  2. Double click the MySQL.prefPane file
    TheSystem Preferenceswindow will appear
  3. Click the Install button
  4. Close the MySQL window

Step 5. Start the MySQL Server

  1. Click the apple logo in the top left hand corner of the screen
  2. Click the System Preferences entry
  3. Click the MySQL icon located under the Other heading
  4. Click the Start MySQL Server button
  5. Enter your password when prompted
  6. Click the OK button
  7. If you have the Firewall on your computer enabled
    1. If you do not want other computers on your network to access your MySQL server
      Click the Deny button
    2. If you do want other computers on your network to access your MySQL server
      Click the Allow button
  8. Confirm that the server started successfully by examining the MySQL window and looking for the text
    The MySQL Server Instance is running

Step 6. Adjust your PATH variable

  1. Open a new Terminal window
  2. Ensure you are in your home directory by executing the following command
    cd ~
  3. Open the .profile file for editing with vi by executing the following command
    vi .profile
  4. Scroll down to the bottom of the page using the arrow keys
  5. Start a new line by pressing the o key
  6. Enter the following line
    PATH=/usr/local/mysql/bin:$PATH
  7. Press the esc key
  8. Save the file and quite vi by entering the following command
    :wq
  9. Close the Terminal window
  10. Open a new Terminal window
  11. Confirm that the path is configured correctly by executing the following command
    mysql –version
  12. If you see output like this the path is configured correctly
    mysql  Ver 14.14 Distrib 5.5.9, for osx10.6 (i386) using readline 5.1
  13. If you see an error
    Confirm that steps 6.2 – 6.9 have been completed successfully

Step 7. Secure the Initial MySQL Accounts

  1. Open a new Terminal window
  2. Connect to the MySQL server by executing the following command
    mysql -u root
  3. If you see an error
    Confirm that steps 5 and 6 have been completed successfully
  4. Confirm that the initial accounts have been created by executing the following SQL statement
    SELECT User, Host, Password FROM mysql.user;
  5. If you see a output table listing three columns that contain details of the root user and blank passwords
    Continue with step 7.7
  6. If you do not see the output table confirm that step 7.2 completed successfully
    If the problem continues there is an error occurring that is outside the scope of this procedure. Consult the MySQL Reference Manual for further information
  7. Set the root user password using the following SQL statement
    UPDATE mysql.user SET Password = PASSWORD(‘{password}‘) WHERE User = ‘root’;
    Where {password} is replaced with your chosen password
  8. If you see output that states in part Query OK, 4 rows affected (0.00 sec) continue with the step 7.10
  9. If you see an error message retry step 7.7
  10. Make the MySQL server use these new password by executing the following SQL statement
    FLUSH PRIVILEGES;
  11. If you see output that states in part Query OK, 0 rows affected (0.00 sec) continue with the step 7.13
  12. If you see an error message retry step 7.10
  13. Remove the first anonymous account by executing the following SQL statement
    DROP USER ”@’localhost’;
    Be careful with the quotes in the line above it starts with two single quotes, and not a double quote.
  14. If you see output that states in part Query OK, 0 rows affected (0.00 sec) continue with the step 7.16
  15. If you see an error message retry step 7.10
  16. Remove the first anonymous account by executing the following SQL statement
    DROP USER ”@’{host_name}‘;
    Where {host_name} is the hostname of your computer
    Be careful with the quotes in the line above it starts with two single quotes, and not a double quote.
  17. If you see output that states in part Query OK, 0 rows affected (0.00 sec) continue with the step 7.19
  18. If you see an error message retry step 7.16
  19. Exit the mysql client application by entering the following command
    quit
  20. Close the Terminal window

Step 8. Download the MySQL Workbench installer

  1. Go to the following website in your internet browser
    http://dev.mysql.com/downloads/workbench/5.2.html
  2. Scroll down the page a little way
  3. Ensure the Mac OS X option is selected in the Select Platform drop down box
  4. Scroll down the page a little further
  5. Click the Download button
  6. Click the No thanks, just take me to the downloads! link to skip the user registration prompt
  7. Click the HTTP or FTP link to the right of one of the automatically selected mirror sites
  8. Wait for the download to complete

Step 9. Install the MySQL Workbench Software

It is assumed that the file that was downloaded in step 8 was saved by your browser into the standard Downloads folder. If this is not the case use the folder specific to your system in step 9.1

  1. Open the downloads folder by clicking the downloads folder icon in your dock
  2. Double click the mysql-workbench-gpl-5.2.32-osx-i686.dmg file
  3. Drag the MySQLWorkbench icon in the MySQL Workbench window to theApplications folder in your Dock
  4. What for the application file to be copied
  5. Close the MySQL Workbench window

Step 8. Cleanup

  1. Close the mysql-5.5.9-osx-10.6-x86_64 window
  2. Click and drag the mysql-5.5.9-osx10.6-x86_64 icon on your desktop to the Ejecticon
    Once you start dragging this icon the Trash icon will change into the Eject icon
  3. Delete the mysql-5.5.9-osx10.6-x86_64.dmg file
  4. Click and drag the MySQL Workbench icon on your desktop to the Eject icon
  5. Delete the mysql-workbench-gpl-5.2.32-osx-i686.dmg file

The MySQL server is now up and running and ready to be used. The MySQL Workbench software, a GUI application for working with the MySQL server and MySQL databases is also installed and ready to be used.

Appendix A. Determining the hostname of your computer

  1. Open a new Terminal window
  2. Enter the following command
    hostname
  3. Take note of the output
    The output from this command is the hostname required in step 7.16
  4. Close the Terminal window

Posted on Saturday, 2 July, 2011, in Uncategorized. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: