Thursday, August 26, 2010

MYSQL:Installation Steps

MYSQL:Installation Steps

1.Add a login user and group for mysqld to run as:
root@stageserver:~# groupadd mysql
root@stageserver:~# useradd -g mysql mysql

2.Choose the directory under which you want to install the MYSQL. And change the location current MYSQL directory
root@stageserver:~# cd /opt

3.Unzip the package which creates the installation directory. Then create a symbolic link to that directory:
gunzip < /home/stageserver/mysql-advanced-gpl-5.1.45-linux-i686-glibc23.tar.gz | tar xvf - Symbolic Link- ln -s /opt/mysql-advanced-gpl-5.1.45-linux-i686-glibc23 /usr/local/mysql Change location into the installation directory: i.e..:/usr/loca/mysql cd /usr/local/mysql 

4.You should add the full path name of this directory to your PATH environment variable so that your shell finds the MySQL programs properly root@stageserver:/usr/local/mysql#PATH=$PATH:/usr/local/mysql/bin Include the same in bash profile file (.profile)– PATH=$PATH:/usr/local/mysql/bin

5.Change ownership of the directory to “mysql” user group. root@stageserver:/usr/local/# chown -R mysql . root@stageserver:/usr/local/# chgrp -R mysql . 

 6.If you have not installed MySQL before, you must create the MySQL data directory and initialize the grant tables: root@stageserver:/usr/local/mysql# scripts/mysql_install_db –user=mysql

 7.Restart the server root@stageserver:~# reboot

 8.Run the following commands as root in the installation directory to change the ownership root@stageserver:/usr/local/mysql# chown -R root . root@stageserver:/usr/local/mysql# chown -R mysql data

 9.To Start mysql automatically in startup by editing file /etc/rc.local and adding the below line at the last before the line “exit 0” /bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &' please include this line bash profile - .profile

 10.Starting the server form the /usr/local/mysql directory 

 11.Secure the installation by running the below command root@stageserver:/usr/local/mysql#bin/mysql_secure_installation 

 12.Check the mysql version by using following command root@stageserver:# bin/mysqladmin version -uroot -p Enter password: enter your password here This should result you mysql version which you have installed Server version 5.1.45-enterprise-gpl-advanced

 13.Verify that you can shut down the server: root@stageserver:/usr/local/mysql#bin/mysqladmin -u root shutdown –p 

 14. Verify that you can start the server again. Do this by using mysqld_safe or by invoking mysqld directly. For example: root@stageserver:/usr/local/mysql# bin/mysqld_safe --user=mysql --log & 

 15 .Reboot the system and see if mysql is automatically started by checking the mysql version again as step 13. 16.Place your my.cnf in the /usr/local/mysql directory