MySql Installation

MySQL is the most popular open source database. It offers excellent speed and reliability. For many applications, the license is free. You should check which licensing option fits your needs.

Note MySql comes preinstalled on many Linux flavors. You may wish to update to the latest version. The following focusses on Mac OS X.

 

Summary

The following summarizes the straight forward installation
Download
Install the Server and Clients
OS Xrun mysql-standard-4.0.16.pkg
Linux

rpm -i server-package
rpm -i client-package
Automate Startup
OS Xrun MySQLStartupItem.pkg
Linuxrpm did this
Start the Server and Clients
OS Xsudo /Library/StartupItems/MySQL/MySQL start
Linuxrpm did this
Configure Your Installation run admin scripts
Install MySQL Java Connector extract, copy to library, form symbolic links
 

Download

The main site for MySql is http://www.mysql.com. You will need both the database server & standard clients and the Java connector.

database server & standard clients

  • Click the download tab at the top of the MySql Site
  • Look for MySQL database server & standard clients. and click the desired version. In general, you will want the latest stable/production version for your platform. The current production version is 4.0 with the link at http://www.mysql.com/downloads/mysql-4.0.html
  • Find the download for you version. For Mac OSX 10.2 and later, the easiest to use is the disk image mysql-standard-4.0.16.dmg. For Mac OS X 10.1 or earlier, you will need a tar ball.

For Linux, the easiest approach is perhaps to use the rpms. Download the rpms for the server and the client.

Java connector

The Java Connector enables java to work with the MySql server.
  • Click the Connector/J link under the MySql Product at the top of the page.
  • Click the desired version under Downloads, Licensing, and Support. The latest production is MySQL Connector/J 3.0
  • Download the desired source and binaries in the desired format. These include zip or tar.gz. The following assumes tar.gz.
 

Install the Server and Clients

Refer to the instructions with your distribution. The following gives an overview.

Linux

For Linux You need to install the packages as root.


	rpm -i server-package
	rpm -i client-package

This should place executables in /usr/bin and set up various files. At this point the server should be running and you should be able to run the client by executing mysql. Thus you should be able to skip to Configure Your Installation.

Mac OSX

The ReadMe.txt provides details on how to install and configure. Read and follow the directions.

The installer will upack the distribution and place it in /usr/local It will also link the /usr/local/mysql to the installed version

The following summarizes the steps.

If you are using using the package, you will do the following.

  1. Open Disk Image. If needed, double click on the open the disk image to mount it.
  2. Launch Installer. Double click the mysql-standard-4.0.16.pkg to start the installation.
  3. Provide information for admininstratior
  4. Agree to license
  5. Follow directions.

If you use the tar bar, you will need to extract the tar ball and run the installion script. You may also need to change the ownership of some files.

 

Automate Startup

This is optional. This will start the database server when you start the computer. The basic steps are
  • Creates the folder /Library/StartupItems/MySQL
  • adds a variable MYSQLCOM=-YES- to the system configuration file /etc/hostconfig.

To disable the server start up, set MYSQLCOM=-NO-

If you are using using the package, Double click the MySQLStartupItem.pkg and follow the directions. You may have a problem on selecting the start up disk. If you do, click the back button and then forward. This usually works and the start up disk will be green.

 

Start the Server and Clients

if you enabled automatic restart you can restart the computer (very inelegant) or type the following in terminal,


	sudo /Library/StartupItems/MySQL/MySQL start
Otherwise you can do it manually with. The samples

	cd  /usr/local/mysql
	./bin/safe_mysqld --user=mysql &

You should now be able to use the clients and administration tools. Try the following in a terminal.


	/usr/local/mysql/bin/mysql
 

Configure Your Installation

The following steps are optional but are generally desirable.

Define root password.

MuSql allows the user named root full access to the system. The default installation gives root a blank password. Thus it is a good idea to change this. The com

Set a password for the root user

For the Mac OSX, the executable should be in /usr/local/mysql/bin.


    /usr/local/mysql/bin/mysqladmin -u root password 
 
    /usr/local/mysql/bin/mysqladmin -u root -h `hostname` password 

The second command may give an error.

TFor linux install location should /usr/bin.


	/usr/bin/mysqladmin -u root password 'new-password'
	/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Set default login info.

This lets you start a mysql client without needing to enter the user or passward.

In your home directory create a file .my.cnf with the following contents


[client]
user=root
password=

Add mysql executables to your path.

If the executables are not in a standard path such as /usr/bin, you may want to add the command path. Thus you can type mysql rather than /usr/local/mysql/bin/mysql.

You will need to edit you login file (either user or system). Basic options are

  • Add aliases
    
         alias mysql '/usr/local/mysql/bin/mysql'
         alias mysqladmin '/usr/local/mysql/bin/mysqladmin'
    
    
  • Add /usr/local/mysql/bin to your path.
 

Install MySQL Java Connector

We will only need access to the java archive for the connector. The following describes one way to set up access to it using a terminal window. You can also do most of this in the Finder. Be aware that using File/Make Alias may not work.
  1. Move to the directory with the download.
  2. Extract the tarball. You should see a directory mysql-connector-java-3.0.9-stable.
    
    	tar xzf mysql-connector-java-3.0.9-stable.tar.gz
    

  3. Copy the connector to local java extensions
    
    	cd mysql-connector-java-3.0.9-stable
     	sudo cp mysql-connector-java-3.0.9-stable-bin.jar /Library/Java/Extensions
    

  4. Link jar to generic name
    
    	cd /Library/Java/Extensions
    	sudo ln -s mysql-connector-java-3.0.9-stable-bin.jar mysql-connector.jar
    	sudo ln -s mysql-connector-java-3.0.9-stable-bin.jar jdbc-connector.jar
    

 
 

eden logo Copyright 2004. Lester Pieniazek. All rights reserved Worldwide.