Compiling and Installing MySQL on Linux/CentOS


Download MySQL Source Code fromhttp://dev.mysql.com/downloads/

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> bin/mysqld_safe --user=mysql &
----
yum install ncurses-devel
yum install gcc gcc-c++
libxml2-devel
libxml2-utils
make clean

Follow this command by typing;

#./configure --prefix=/usr/local/mysql --localstatedir=/home/system/data/mysql --disable-maintainer-mode --with-mysqld-user=mysql --enable-large-files-without-debug (enter)
Sit back and wait for a while while configure does its thing, once the system returns the prompt to you issue the following command;

#make (enter)

Unless you have a very fast machine this will take some time, so spend time with your family, grab a beer, go for a walk, or whatever you're into. When you get back, assuming the system has returned the prompt to you issue the following command;
#make install (enter)

Cool !, MySQL is installed, there are only a couple things left to do to get it working, first we need to create a group for MySQL as follows;
#/usr/sbin/groupadd mysql (enter)

Then we create a user called mysql which belongs to the mysql group;
#/usr/sbin/useradd -g mysql mysql (enter)

Now we install the database files as follows;
#./scripts/mysql_install_db (enter)

Then we make a couple minor ownership changes;
# chown -R root:mysql /usr/local/mysql (enter)
# chown -R mysql:mysql /usr/local/mysql/data (enter)

Last but not least, we use vi to add a line the ld.so.conf file as follows;
#vi /etc/ld.so.conf

And we add the following line;
/usr/local/mysql/lib/mysql

Thats it, MySQL is installed, you can run it by issuing the following command;
#/usr/local/mysql/bin/mysqld_safe --user=mysql &

And as long as we're here we might as well set a root password for MySQL as follows;
#/usr/local/mysql/bin/mysqladmin -u root password new_password
Where new_password is the password you want to use.

Starting Apache and MySQL Automatically 
---------------------------------------------------

Lets start with MySQL, as root make your working directory that of the MySQL source directory you worked with earlier, something similar to;
#cd /home/xxxx/mysql-4.0.16

Then, copy the file mysql.server to your /etc/init.d directory as follows;
#cp support-files/mysql.server /etc/init.d/mysql

Ok, lets create some links in the startup folders for run levels 3 and 5.
#cd /etc/rc3.d
#ln -s ../init.d/mysql S85mysql
#ln -s ../init.d/mysql K85mysql
#cd /etc/rc5.d
#ln -s ../init.d/mysql S85mysql
#ln -s ../init.d/mysql K85mysql
#cd ../init.d
#chmod 755 mysql

Thats it for MySQL, it should start automatically now when you reboot your machine!

Comments

1 comment

Kasinath Kottukkal | November 24, 2012 at 12:35 AM

http://themeforest.net/item/webworks-responsive-wordpress-theme/full_screen_preview/1631392

Post a Comment