
How to install MySQL using Source Distribution on Linux:
1. Login as root user.
2. Install the gcc-c++ library
3. Add a login user and group
[root@localhost ~]#grupadd mysql
[root@localhost ~]#useradd -g mysql mysql
4. Download the MySQL sorurce under /usr/local/src/ using this link:
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.38.zip/from/http://mysqlmirror.netandhost.in/
[root@localhost ~]#cd /usr/local/scr
5. Extract this zip file and change the location:
[root@localhost src]#unzip mysql-5.1.38.zip
[root@localhost src]#cd mysql-5.1.38
6. Configure the source and compile it.
[root@localhost mysql-5.1.38]#./configure --prefix=/usr/local/mysql
--prefix option is used to set directory path, where install architecture-independent file For set different values, we can use other options according to our need.
[root@localhost mysql-5.1.38]#make
7. Install the source
[root@localhost mysql-5.1.38]#make install
You might need to run this command as root.
8. For create a configuration file for MySQL
[root@localhost mysql-5.1.38]#cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql-5.1.38]#chown root:sys /etc/my.cnf
9. Change location into the installation directory
[root@localhost mysql-5.1.38]#cd /usr/local/mysql
10. If we run the make install command as root, the installed files will be owned by root.
[root@localhost mysql]#chown -R mysql.mysql .
11. We must create the MySQL data directory and initialize the grant tables
[root@localhost mysql]#./bin/mysql_install_db --user=mysql
12. Now we have to tell the system where to find some of the dynamic libraries that MySQL will need to run.
[root@localhost mysql]#echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
[root@localhost mysql]#ldconfig
13. Most of the MySQL installation can be owned by root. The exception is that the data directory must be owned by mysql.
[root@localhost mysql]#chown -R root .
[root@localhost mysql]#chown -R mysql var/
14. If we want to MySQL to start automatically at booting time.
[root@localhost mysql]#cp /usr/local/src/mysql-5.1.38/support-files/mysql.server \
/etc/rc.d/init.d/mysql
[root@localhost mysql]#chmod +x /etc/rc.d/init.d/mysql
[root@localhost mysql]#chkconfig mysql --level 35 on
15. Create link for all binary files for mysqld
[root@localhost mysql]#for file in *;do ln -s /usr/local/mysql/bin/$file /usr/bin/$file;done
16. After everything has been installed, we test it:
[root@localhost mysql]#mysqld_safe --user=mysql &
[root@localhost mysql]#/etc/rc.d/init.d/mysql start
17. Set a passowrd for the MySQL root user:
[root@localhost mysql]#mysqladmin -u root password 'NEW-PASSWORD'
18. Login on MySQL prompt
[root@localhost mysql]#mysql -u root -pNEW-PASSWORD