Knowledge Base  2.0 Installing MySQL
2.0 Installing MySQL

installing MySQL on Mac OS X

  Link to this page use http://www.markfennell.com/kb.php?id=000086

I use my Mac as a web development server since it runs a FreeBSD variant called Darwin. My actual website (the one you are viewing) runs on a dedicated server running Red Hat linux.

I have set up my local machine to behave in the same way as my live website, allowing for development offline testing and then seamless upload.

My Live server runs Perl, PHP and MySQL, as such they needed to be installed on my Mac in order to set up a local development environment.

Installing MySQL on Mac OS X is easy. Download the Complete MySQL package from serverlogistics.

Once you have downloaded the file, mount the .dmg file. To install it run the MySQL.pkg file

Follow the instruction, enter your authorization password and install MySQL. The Following is taken from the Install Guide that accompanies the install.

The installer creates a user called "mysql" on your system, which is the user that the mysql processes will run as. The installer assigns the highest available UID to the mysql user. There is also no password assigned to this user, and you will not be able to login as mysql either. It is supposed to be this way. Do not assign a password to the mysql user, it is not a security risk. The mysql user exists solely as an unprivileged user in which to run the mysql processes.

The installer will not automatically start the MySQL server after an initial installation of the MySQL package. This is because the MySQL server has not been initialized yet.

The installer will create a symlink from /Library/MySQL to /usr/local/mysql if /usr/local/mysql does not already exist. Many 3rd party libraries and applications may require MySQL to reside in this location in order to work properly.

Modify Your $PATH

This allows you to simply type mysql from the prompt, instead of having to

> /Library/MySQL/bin/mysql

In order to modify your $PATH, you will have to find out which shell you areusing. This can be done easily in the Terminal with the following command:

> echo $SHELL

This will return the path to the shell you are using. In most cases it will return either "/bin/tcsh" (tcsh shell) or "/bin/bash" (bash shell). If you are using the tcsh shell, you will have to modify the file ".tcshrc" located within your home directory. If this file does not exist, then you will have to create a new one. After opening the file in your text editor, add the following line at the bottom of the file

setenv PATH "$PATH":/Library/MySQL/bin

If you are using the bash shell, you will have to edit the file ".bashrc" located in your home directory. If this file does not exist, then you will have to create a new one. After opening the file in your text editor, add the following line at the bottom of the file:

export PATH="$PATH:/Library/MySQL/bin"

Restart the Terminal application. You should now be able to access the MySQL command by simply typing

> mysql

MySQL System Preferences Pane.

To install the MySQL.prefPane, drag and drop the MySQL.prefPane folder to one of two locations.

Preference Panes installed into /Library/PreferencePanes are available to all users through the System Preferences application.

By installing Preference Panes into $(HOME)/Library/PreferencePanes, only the user who's home directory is $(HOME) will be able to use the Preference Pane.

Create the directory if it does not exist. After installing MySQL,prefPane to your desired location, open System Preferences. From the main view, you should see a fourth row of Preference Panes labeled "Other". MySQL should now be listed there with a light switch icon.

If you are upgrading MySQL from a previous version, do not complete this step!

After installing MySQL for the first time, you will need to initialize the database. Initializing the database creates the grant tables

Using System Preferences Open the System Preferences application and select MySQL from the "Other" section of Preference Panels. On the right side of window, just beneath the Start/Stop button, you will see a button labeled "Initialize":

The Initialize button will not be enabled if MySQL is currently running or if the database has already been initialized. Clicking the Initialize button,
will be prompt for your password. This is necessary to ensure that the Preferences application has the proper permissions in which to run the initialization scripts. After entering your password, the System Preferences will attempt to initialize the database. Upon success, you should see the following message

Initializing the database creates the MySQL root account without a password, which is a major security problem. Keep in the mind that the MySQL root user is in no way associated with the system's root user. These two root users arecompletely separate. The same goes for all MySQL database user accounts. They have no system access and are only recognized by MySQL. The MySQL root user acts just like the system's root user in that is has full access over the entire database. Only give the root password out to those you trust.

You can not set the root password if MySQL is not running. To start the MySQL server, click the "Start" button in the MySQL Preferences Pane.

You will be prompted for your password. Upon entering your password, MySQL should start up and the "Status:" section of the Preference Pane should now report that the server is running. After the server is started, the button labeled "Set Root Password" should now be enabled.

Click, and in the new window enter a root password. the current root password is blank.

You should now be able to access mysql from the terminal window. To do so type the following

>mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39 to server version: 4.0.13

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.28 sec)

mysql>

The -u option means user the -p means password you will be prompted to enter it. All going well you should enter the mysql database engine and voila!

The complete mysql manual is included with the distribution, should you have any issues with installation i recommend a thorough perusal of the installation pdf that accompanies the distribution. This is simply what worked for my system.

Links

http://www.serverlogistics.com/mysql.php
http://www.mysql.com


Added: December 01, 2003