Tuesday, July 17, 2012

Install and Configure MySQL using Generic Unix or Linux Binaries

Oracle provides the Generic binaries in the form of tar files. Using generic binaries you will be able to control the configuration and layout.

The MYSQL compressed tar files have names of the form mysql-version-OS.tar.gz.

Generic Unix/Linux Binaries Installation layout
Directory  Contents of Directory
bin            Client programs and the mysqld server
data          Log files, databases
docs         Manual in Info format
man          Unix manual pages
include     Include (header) files
lib            Libraries
scripts      mysql_install_db scripts
share        Miscellaneous support/sample configuration/Install files, including error messages
sql-bench Benchmarks

Before you install, make sure that there are no previous versions of mysql, unless you want to use older version of MySQL.

Command to find old rpms installed on the system
# rpm -qa | grep -i ^mysql
Command to find old mysql directories/files
# Find . –name *mysql* -print
Command to find mysql server process
# ps –ef | grep mysql

Follow the steps to Install and configure MySQL

1. Create mysql user and group
# groupadd -g 100 mysql
# useradd -u 100 -s ksh -d /u01/mysql -r -g mysql mysql
# chown -R mysql:mysql /u01/mysql

2. Login as Mysql and unpack the distribution
# su – mysql
$ tar zxvf /u01/mysql-5.0.45.tar.gz
Create a soft link to 5.0.45
# ln -s /u01/mysql/mysql-5.0.45 5.0.45

3. Create a profile and set the profile
-----.profile file----
MYSQL_BASE=/u01/mysql; export MYSQL_BASE
MYSQL_HOME=/u01/mysql/5.0.45; export MYSQL_HOME
Set the profile
$ . ./.profile

4. Copy sample configuration file and edit the file according to your environment.
$ cp /u01/mysql/5.0.45/support-files/my-small.cnf $MYSQL_HOME/my.cnf
-----my.cnf file----



5. Create mysql database files for mysql server.
$ scripts/mysql_install_db --datadir=/u01/mysql/5.0.45/data --basedir=$MYSQL_HOME

This command creates the default database schemas

6. Start the MySQL Server
$ mysqld_safe --defaults-file=$MYSQL_HOME/my.cnf &

Here we have placed the my.cnf under MYSQL_HOME. You can copy the configuration file to any location and use the path while starting the mysql server.

7. Verify the Mysql process and logs
$ ps –ef  | grep mysql

Verify the error log (log-error=/u01/mysql/mysqld.log) under the path that you mentioned in the my.cnf

Satishbabu Gunukula

1 comment: