Installing MySQL on Linux and Unix

As noted, you have a number of options for installing MySQL on Linux and Unix. The MySQL binaries are available as generic, precompiled binaries for a number of systems, as RPM packages, and as source bundles. The method you use for installation is up to you. In the following sections you’ll see how to install from the RPM package and from source.

Creating a User for MySQL

The MySQL server will be running as a process on your system. Since MySQL must create and manipulate files to maintain the database, and it’s potentially able to accept connections from remote computers, you must create a unique user and group for MySQL.

 # groupadd mysql  # useradd -g mysql mysql 

This creates the mysql group using the groupadd command. The useradd command adds a user to the group specified with the -g switch.

Installing MySQL from the RPM Package

Download the following packages to an appropriate place:

  • MySQL: The base server package

  • MySQL-bench: MySQL benchmarks and test suite

  • MySQL-client: MySQL client applications

  • MySQL-devel: Header files and libraries for development

  • MySQL-shared: MySQL client shared libraries

  • MySQL-Max: The server version that includes InnoDB tables (see Chapter 11 for details on this)

Before you begin the install, make sure you’ve logged on as root. To install the RPM packages, use the RPM package manager application. You have two options with this: you could use the graphical package manager of your choice, or you could place all the RPM files in a single directory and (making sure you are root) execute the following:

 # rpm -i *.rpm 

This will unpack the packages and install all the files into their correct places for your distribution.

To test the installation, run the following command (run all commands from the bin subdirectory of the MySQL installation):

 > mysqlshow 

This will list the databases that come with MySQL. You’re now ready to begin working with MySQL, so you can skip ahead to the “Working with MySQL” section.

Installing MySQL from Source

You can find the entire MySQL source code in a single tarball that will have a name similar to mysql-4.0.x.tar.gz.

Compiling MySQL is a relatively simple operation. If you’re familiar with compiling open-source products, there will be no surprises for you here; even if this is your first attempt in compiling and installing an open-source product, you should have no real difficulty.

The MySQL build scripts will give an error if you’re missing any of the required development utilities. If this happens, you’ll need to install the missing development tools and try again. Linux distributions generally ship with a suitable development environment containing the GNU tools from the Free Software Foundation.

Note 

At the time of writing there were some issues with compiling certain versions of the GNU C/C++ compiler, especially versions 2.96 and 3.0. Check the MySQL Web site for the latest news on compiler compatibility; also read the release notes of the tarball you downloaded.

Transfer the source tarball to the target machine, and place it in an appropriate directory for compiling. This shouldn’t be the final location of your MySQL installation.

Unpack the tarball to extract the source code.

 $ tar zxvf mysql-4.0.x.tar.gz 

You must use the GNU version of the tar utility for this to work. On systems without GNU tar, you may need a two-step extraction to decompress the tarball.

 $ gunzip mysql-4.0.x.tar.gz  $ tar xvf mysql-4.0.x.tar 

However, Solaris’s version of tar causes problems with the decompression, so you should install GNU tar instead.

The extraction process will make a new directory, related to the version of MySQL you’re building. Move into that directory.

 $ cd mysql-4.0.x 

In this directory, you’ll find a file, INSTALL-SOURCE, that contains detailed manual build instructions. This can be useful in the unlikely event that the automated method outlined in this appendix fails for some reason.

The build process uses the configure configuration script to tailor the build parameters to your specific environment. To accept all defaults, you can simply run configure without arguments.

 $ ./configure 

The configuration script can take a number of parameters that alter the features built into MySQL. One of these features is the ability to use different implementations for its database tables. You can choose table types optimized for speed or features such as transactions. You will use the InnoDB table type in Chapter 11, so you need to tell the configuration script to include support for this table type.

 $ ./configure --with-innodb 

For a full list of options, you can use the --help argument.

Once the compilation is configured, you can build the software with the make utility.

 $ make 

If all goes well, you should see a large number of compilations proceeding. When make has finished, you need to copy the programs to their final resting places. Use the make install command to do this, but you need to be root first.

 $ su  # make install 

Now you have a complete but empty installation of MySQL in the directory /usr/local/mysql and its subdirectories. You have another couple of steps to take before you’re ready to use MySQL. The initial database doesn’t contain any user definitions or privileges that MySQL will use to control access to your data. To create the privilege tables, you need to run a script provided for this purpose. Again, this must be run as root after moving into the /usr/local/mysql directory.

 # scripts/mysql_install_db 

The MySQL files need to have the correct ownership set that’s to be owned by the MySQL user. After using make install, all the files are owned by root. You want root to own everything except the /var subdirectory, and you do this by using the recursive form of chmod and chgrp.

 # chown -R root /usr/local/mysql  # chown -R mysql /usr/local/mysql/var  # chgrp -R mysql /usr/local/mysql 

You’re now in much the same situation as you would have been had you installed MySQL from binary packages. Now it’s time to turn your attention to setting up MySQL to run.

To start the MySQL server, execute the following:

 # /etc/rc.d/init.d/mysql start 

To stop the server, run the following:

 # /etc/rc.d/init.d/mysql stop 

To test the installation, run the following command (run all commands from the bin subdirectory of the MySQL installation):

 > mysqlshow 

This will list the databases that come with MySQL. You’re now ready to begin working with MySQL.



Pro Jakarta Tomcat 5
Pro Apache Tomcat 5/5.5 (Experts Voice in Java)
ISBN: 1590593316
EAN: 2147483647
Year: 2004
Pages: 94

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net