To install MySQL from source you need to install some dependencies and tools co compile from source
MySQL released 5.5 version in December 2010. This version seems to be more efficient with improvements like better improved scalability on multi-core CPU, InnoDB storage engine becomes the default engine for new tables or integration of semisynchronous replication. This version is recommended for production environments. It's interesting for administrator to thinking about upgrading. Much systems executes 5.1 version and sometimes the upgrade can be scary ... Here we are going to see how to install 5.5 version on new systems. First we need to install some packages that are needed by MySQL. So installs (or be sure that they all have been installed): bison, bzr, cmake, gcc-c++ ncurses-devel.
# yum groupinstall 'Development Tools'
MySQL released 5.5 version in December 2010. This version seems to be more efficient with improvements like better improved scalability on multi-core CPU, InnoDB storage engine becomes the default engine for new tables or integration of semisynchronous replication. This version is recommended for production environments. It's interesting for administrator to thinking about upgrading. Much systems executes 5.1 version and sometimes the upgrade can be scary ... Here we are going to see how to install 5.5 version on new systems. First we need to install some packages that are needed by MySQL. So installs (or be sure that they all have been installed): bison, bzr, cmake, gcc-c++ ncurses-devel.
# yum groupinstall 'Development Tools'
# yum install -y bison bzr cmake gcc-c++ ncurses-devel
Then add new mysql account and group:
# groupadd mysql
# useradd -r -g mysql mysql
Now we need download last mysql 5.5 tar.gz archive, choose the mirror directly on mysql website.
wget http://URL_OF_MIRROR/mysql-5.5.16.tar.gz
Extracting tar.gz archive
tar -xvzf /downloads/mysql-5.5.16.tar.gz
Now go into extracted directory and execute cmake:
cd /downloads/mysql-5.5.16/
cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql \-DMYSQL_DATADIR=/var/lib/mysql \
-DSYSCONFDIR=/etc \
-DINSTALL_PLUGINDIR=/opt/mysql/lib/mysql/plugin
Note that I use /opt/mysql for basedir /var/lib/mysql for datadir, you can use others directories by specifing them with 'DCMAKE_INSTALL_PREFIX' and '-DMYSQL_DATADIR' options. When cmake finish to work, we can launch the make .
make
Next, if we don't encounter errors, we launch the install:
make install
Now, we create symbolic links to have mysql commands in shell:
ln -s /opt/mysql/bin/* /usr/bin/
Assign owner and group:
cd /opt/mysql/
chgrp -R mysql .
chown -R root .
chown -R mysql data
Default database installation:
scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql/
Copy a mysql default configuration file:
cp support-files/my-medium.cnf /etc/my.cnf
Copy mysql init.d script and make it executable:
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
Now edit this init.d script for customize both basedir and datadir paths:
vim /etc/init.d/mysqld
## replace
basedir=
basedir=
## by
basedir=/opt/mysql
datadir=/var/lib/mysql
Finally, we can launch mysql server and begin to use it:
/etc/init.d/mysqld start
and we are done