MySQL DBA Tips Corner

     Return to the MySQL DBA Tips Corner.


Installing MySQL 4.0.20 - (Linux)

by Jeff Hunter, Sr. Database Administrator


Contents

  1. Overview
  2. Downloading the MySQL Software
  3. Uninstalling Any Previous MySQL Installation
  4. Operating System Account
  5. Uncompress / Installing Binary Version of MySQL
  6. Starting and Stopping the MySQL Database Software
  7. Testing the Installation
  8. .bash_profile For The mysql User Account


Overview

This article provides the steps necessary to successfully install the binary version of MySQL, release 4.0.20, on RedHat Linux Fedora Core 1. These procedures should work as well on versions of RedHat as early as version 6.2.

I typically install MySQL in /usr/local/mysql as the UNIX root account. I then create a UNIX mysql account that will have access to manage databases.

Once you've installed MySQL, you will need to initialize the grant tables, start the server, and make sure that the server works okay. You may also elect to arrange for the server to be started and stopped automatically when your system starts up and shuts down.

Installing the grant tables is accomplished by running the mysql_install_db script. This creates the mysql database which will hold all database privileges, the test database which you can use to test MySQL, and also privilege entries for the user that run mysql_install_db and a root user (without any passwords).


Downloading the MySQL Software

At the time of this writing, the most current stable release of MySQL is release 4.0.20 and that is the version we will be installing in this article. For each MySQL release, there are three different packages that can be downloaded and installed based on certain requirements.

The Standard binaries now include the InnoDB storage engine and is sufficient for most users. This will be the set of binaries we will install and configure in this article.

MySQL also includes the Max version set of binaries that includes additional features such as the Berkeley DB storage engine and other features that have not been exhaustively tested or are not required for general usage, such as user-defined functions (UDFs), and BIG_TABLE support. When these features have matured and proven to be stable, they will be incorporated into future releases of the Standard binaries.

The Debug binaries have been compiled with extra debug information, and are not intended for production use, because the included debugging code may cause reduced performance.

Use the following URL to download the Linux Binaries for MySQL release 4.0. Keep in mind that I will be downloading the Linux (x86, libc6) release - not the RPM release.

http://dev.mysql.com/downloads/mysql/4.0.html

The file I downloaded was "mysql-standard-4.0.20-pc-linux-i686.tar.gz".


Uninstalling Any Previous MySQL Installation

For users running Red Hat Linux, you may already have a release of MySQL installed (i.e. MySQL 3.23). For this example, I will be installing MySQL on Red Hat Linux (Fedora Core 1) and this release of Red Hat includes MySQL release 3.23:
# rpm -qa | grep -i mysql
libdbi-dbd-mysql-0.6.5-7
MySQL-python-0.9.1-9
perl-DBD-MySQL-2.9002-1
mod_auth_mysql-20030510-3
php-mysql-4.3.3-6
mysql-3.23.58-4
mysql-bench-3.23.58-4
mysql-server-3.23.58-4
freeradius-mysql-0.9.1-1
mysql-devel-3.23.58-4
qt-MySQL-3.1.2-14
You will want to uninstall this release of MySQL before continueing with the installation of MySQL 4.0.

You can use RPM to uninstall the above packages as follows:

# rpm -e libdbi-dbd-mysql
# rpm -e MySQL-python
# rpm -e mod_auth_mysql
# rpm -e php-mysql
# rpm -e mysql-bench
# rpm -e mysql-server
# rpm -e freeradius-mysql
# rpm -e mysql-devel
# rpm -e mysql perl-DBD-MySQL MyODBC qt-MySQL
In addition to removing all MySQL packages, you will also want to remove any mysql group and user that may already be created. The following command will remove both the mysql group as well as the mysql group:
# userdel mysql


Operating System Account

Create MySQL User Account:
# cd /usr/local
# groupadd mysql
# useradd -c "MySQL Software Owner" -g mysql mysql
# passwd mysql
Changing password for user mysql.
New password: **********
BAD PASSWORD: it is too short
Retype new password: **********
passwd: all authentication tokens updated successfully.


Uncompress / Installing Binary Version of MySQL

# su -
# cp mysql-standard-4.0.20-pc-linux-i686.tar.gz /usr/local
# cd /usr/local
# gunzip mysql-standard-4.0.20-pc-linux-i686.tar.gz
# tar xvf mysql-standard-4.0.20-pc-linux-i686.tar
# ln -s mysql-standard-4.0.20-pc-linux-i686 mysql
# cd mysql

# scripts/mysql_install_db --user=mysql
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
040803 23:21:45  Warning: Asked for 196608 thread stack, but got 126976
040803 23:21:45  ./bin/mysqld: Shutdown Complete


To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h linux2 password 'new-password'
See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

# chown -R root  .
# chown -R mysql data
# chgrp -R mysql .


Starting and Stopping the MySQL Database Software

Starting the MySQL Database
# su -
# cd /usr/local/mysql
# bin/mysqld_safe --user=mysql &
Starting mysqld daemon with databases from /usr/local/mysql/data
Stopping the MySQL Database
# su -
# cd /usr/local/mysql
# bin/mysqladmin -u root shutdown
040803 23:36:27  mysqld ended

[1]+  Done                    bin/mysqld_safe --user=mysql


Testing the Installation

Ensure that the MySQL Software, the mysqld server, is running and you have set up the initial MySQL grant tables containing the privileges that determine how users are allowed to connect to the server. This is normally done with the mysql_install_db script.


.bash_profile For The mysql User Account

.bash_profile

# +------------------------------------------------------------+ # | FILE : .bash_profile | # +------------------------------------------------------------+ # +------------------------------------------------------------+ # | GET THE ALIASES AND FUNCTIONS | # +------------------------------------------------------------+ if [ -f ~/.bashrc ]; then . ~/.bashrc fi # +------------------------------------------------------------+ # | SOURCE GLOBAL DEFINITIONS | # +------------------------------------------------------------+ if [ -f /etc/bashrc ]; then . /etc/bashrc fi # +------------------------------------------------------------+ # | GET THE ALIASES AND FUNCTIONS | # +------------------------------------------------------------+ umask 022 EDITOR=vi; export EDITOR TERM=xterm; export TERM TMPDIR=/tmp; export TMPDIR alias ls="ls -FA" alias s="screen -DRRS iPad -t iPad" # +------------------------------------------------------------+ # | SETUP SEARCH PATH | # +------------------------------------------------------------+ PATH=/usr/local/mysql/bin:/usr/local/mysql/support-files:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/java/bin:. export PATH # +------------------------------------------------------------+ # | SETUP JAVA ENVIRONMENT (optional) | # +------------------------------------------------------------+ JAVA_HOME=/usr/local/java export JAVA_HOME CLASSPATH=. CLASSPATH=${CLASSPATH}:/u01/app/oracle/product/9.2.0/jdbc/lib/ojdbc14.jar export CLASSPATH # +------------------------------------------------------------+ # | FINISH OFF THE SCRIPT | # +------------------------------------------------------------+ echo ".bash_profile executed for user $USER"


Copyright (c) 1998-2014 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Wednesday, 30-Jun-2010 14:30:42 EDT
Page Count: 2686