Online Book Reader

Home Category

MySQL in a Nutshell [7]

By Root 21968 0
To do this, enter the following:

make

make install

cd /usr/local/mysql

./scripts/mysql_install_db

The first command builds the binary programs. If it’s successful, you need to enter the second line to install the binary programs and related files in the appropriate directories. In the next line, you’re changing to the directory where MySQL was installed. If you configured MySQL to be installed in a different directory, you’ll have to use that one instead. The last command uses a script provided with the distribution to generate the initial privileges or grant tables.

All that remains now is to change the ownership of the MySQL programs and directories. You can do this by entering the following:

chown -R mysql /usr/local/mysql

chgrp -R mysql /usr/local/mysql

The first command changes ownership of the MySQL directories and programs to the mysql user. The second command changes the group owner of the same directory and files to mysql. These file paths may be different depending on the version of MySQL you installed and whether you configured MySQL for different paths.

With the programs installed and their file ownerships properly set, you can start MySQL. You can do this in several ways. To make sure that the daemon is restarted in the event that it crashes, enter the following from the command line:

/usr/local/mysql/bin/mysqld_safe &

This starts the mysqld_safe daemon, which will in turn start the MySQL server mysqld. If the mysqld daemon crashes, mysqld_safe will restart it. The ampersand at the end of the line instructs the shell to run the daemon in the background.

To have MySQL started at boot time, copy the mysql.server file, located in the support-files subdirectory of /usr/local/mysql, to the /etc/init.d directory. To do this, enter the following from the command line:

cp support-files/mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql

chkconfig --add mysql

The first line follows a convention of placing the startup file for the server in the server’s initial daemons directory with the name mysql. You should change the file paths to the equivalent directory on your system. The second command makes the file executable. The third sets the run level of the service for startup and shutdown.

Now that MySQL is installed and running, you need to make some postinstallation adjustments that are explained in the last section of this chapter (Postinstallation”).

Unix Binary Distributions

Installing MySQL with a binary distribution is easier than using a source distribution and is the recommended choice if a binary distribution is available for your platform. The files are packaged together into an archive file and then compressed before being put on the Internet for downloading. Therefore, you will need a copy of GNU tar and GNU gunzip to be able to unpack the installation files. These tools are usually included on all Linux systems and most Unix systems. If your system doesn’t have them, though, you can download them from the GNU Project’s site (http://www.gnu.org).

Once you’ve chosen and downloaded the installation package, enter something like the following from the command line as root to begin the MySQL installation process:

groupadd mysql

useradd -g mysql mysql

cd /usr/local

tar xvfz /tmp/mysql-version.tar.gz

The first command creates the user group mysql. The second creates the user mysql and adds it to the group mysql at the same time. The next command changes to the directory where the MySQL files are about to be extracted. In the last command, you use the tar utility (along with gunzip via the z option) to unzip and unpack the source distribution file that you downloaded. The word version in the name of the installation file is replaced with the version number—that is to say, use the actual path and name of the installation file that you downloaded as the second argument of the tar command. For Sun Solaris systems, you should use gtar instead of tar.

After running the previous commands, you need to create a symbolic link to the directory created by tar in /usr/local:

ln -s /usr/local/mysql-version

Return Main Page Previous Page Next Page

®Online Book Reader