HomeMySQL Page 3 - MySQL Configuration and Installation
Installing MySQL on UNIX from a Binary Tarball Distribution - MySQL
If you ever wanted to start using the open source MySQL server application on your computer, this article is for you. It will show you how to obtain, install, configure, and test the MySQL server on your system, whether you are running UNIX or Windows. It is excerpted from My SQL The Complete Reference by Vikram Vaswani (McGraw-Hill/Osborne, 2003; ISBN: 0072224770).
In case you’re using a Linux distribution that doesn’t support RPM, you can also install MySQL using a binary tarball from the MySQL web site.
Installing from a binary distribution essentially means that you need to perform the installation steps manually rather than letting RPM automatically take care of it for you. Here’s how you go about doing it:
1. Ensure that you’re logged in as root:
[user@host]# su - root
2. Extract the content of the tarball to an appropriate directory on your system—I’ll assume this location is /usr/local/. Remember to replace the file name in italics with the file name of your tarball.
[root@host]# cd /usr/local [root@host]# tar -xzvf mysql-standard-4.0.9-gamma-pc-linux-i686.tar.gz
The MySQL files should get extracted into a directory named according to the format mysql-version-os-architecture—for example, mysql-standard-4.0.9-gamma-pc-linux-i686.
3. Now you’ll notice that the directory created in the previous step has a somewhat long and cumbersome directory name— something like mysql-standard-4.0.9-gamma-pc-linux-i686. For ease of use, create a soft link to this directory named mysql in the same location.
[root@host]# ln -s mysql-standard-4.0.9-gamma-pc-linux-i686 mysql
4. Change into this directory, and take a look at how the files are arranged. You should see something like Figure 3-3. (Take a look at the sidebar entitled “Up a Tree” for more information on what each directory contains.)
Figure 3-3. The directory structure obtained on unpackaging of a MySQL binary tarball on Linux
Up a Tree If you have the time (and the inclination), you might find it instructive to explore the MySQL directory structure to help you better understand where the important files are located.
For a binary distribution, the directory structure for a typical MySQL installation looks like this:
<mysql-install-root> |-- bin [client and server binaries] |-- data [databases and error log] |-- include [header files] |-- lib [compiled libraries] |-- man [manual pages] |-- mysql-test [test suite] |-- share [error messages in different languages] |-- scripts [startup, shutdown and initialization scripts] |-- sql-bench [queries and data files for benchmark tests] |-- support-files[sample configuration files] |-- tests [test cases]
For a source distribution, the directory structure for a typical MySQL installation looks like this:
<mysql-install-root> |-- bin [client binaries] |-- libexec [server binaries] |-- var [databases and error log] |-- lib [compiled libraries] |-- include [header files] |-- info [info pages] |-- man [manual pages] |-- mysql-test [test suite] |-- share [error messages in different languages] |-- sql-bench [queries and data files for benchmark tests]
Take a look at the documentation that ships with the MySQL distribution for a more detailed discussion of this directory structure.
5. The MySQL database server can run as either the system root user or any other user on the system. From the security point of view, it’s considered a bad idea to run the MySQL database server as root ; hence, it becomes necessary for you to create a special mysql user and group for this purpose.
You can accomplish this using the groupadd and useradd commands:
[root@host]# groupadd mysql [root@host]# useradd –g mysql mysql
6. Run the initialization script, mysql_install_db, that ships with the program: