Customizing MySQL Server

Here we will learn some common ways of customizing MySQL Server.

Customizing MySQL Server involves the following steps.
1) Changing the port on which MySQL Server binds
2) Installing libdbi driver for MySQL Server



1) Changing the port on which MySQL Server binds
MySQL Server by default binds on the port 3306. If we want MySQL Server to bind on a different port, we must make the following changes.

Open the MySQL Server configuration file /etc/my.cnf. Under the [mysqld] section, change the value of port to what we need. I changed the port from 3306 to 3308. Now it must look as shown below.

port = 3308


Restart the mysql service.

# service mysql restart
TIP:
If we want MySQL Server to bind to multiple ports, we must use internal routing rules. For example iptables.

 



2) Installing libdbi driver for MySQL Server
libdbi is a database independent abstraction layer in C, similar to the DBI in Perl. It uses a generic set of code, using which programmers can leverage the power of multiple databases and multiple simultaneous database connections by using this framework.
NOTE:
Installation is performed based on the rule iRULE5.
Read more about DBI and libdbi.

In order to have this feature for MySQL Server we have to install the libdbi framework and the corresponding database driver. In our case, the MySQL driver.
a) Installing libdbi framework
b) Installing libdbi-drivers for MySQL

a) Installing libdbi framework
libdbi framework is available from the sourceforge project website. Goto http://sourceforge.net/projects/libdbi/files/libdbi/. Download the file libdbi-0.9.0.tar.gz.
The size of downloaded file will be 1.1 MB.

Make sure you have copied the downloaded file libdbi-0.9.0.tar.gz to /usr/src/. In the terminal, change to /usr/src/ directory.

# cd /usr/src


Extract the gzipped tarball

# tar -zxvf libdbi-0.9.0.tar.gz
OPTIONS EXPLAINED

-x
extract files from an archive

-v
verbosely list files processed

-z
filter the archive through gzip

-f
use archive file or device ARCHIVE

We will now have a directory libdbi-0.9.0 with the extracted files.

Change to the directory libdbi-0.9.0 in terminal.

# cd libdbi-0.9.0


In the terminal, execute the configure script present in that directory.

# ./configure

configure will check our system for required dependencies, assigns values for system-dependent variables and use these values to generate the Makefile.


Execute make.

# make

make will look at our Makefile, compile our program code and create the executables in the sequence described.


Execute make install.

# make install
OPTIONS EXPLAINED

install
install will look for the target install in Makefile.PL, and install DBD::mysql to the specified location.

make will look for the target install in Makefile, and install libdbi framework to /usr/local.
Run ldconfig.
NOTE: Before running this command, make sure you have added the directory /usr/local/ to the System library path as instructed here.

# ldconfig

ldconfig scans the ld.so.conf.d directory and updates the shared library cache; so that dynamic-linker can find them during runtime.



b) Installing libdbi-drivers for MySQL
libdbi-drivers includes drivers for all databases such as MySQL, PgSQL, SQLite3 etc. It is available from the sourceforge project website. Goto http://sourceforge.net/projects/libdbi-drivers/. Download the file libdbi-drivers-0.9.0.tar.gz.
The size of downloaded file will be 1.7 MB.


Make sure you have copied the downloaded source code of libdbi drivers to /usr/src/. In the terminal, change to /usr/src/ directory.

# cd /usr/src


Extract the gzipped tarball

# tar -zxvf libdbi-drivers-0.9.0.tar.gz
OPTIONS EXPLAINED

-x
extract files from an archive

-v
verbosely list files processed

-z
filter the archive through gzip

-f
use archive file or device ARCHIVE

We will now have a directory libdbi-drivers-0.9.0 with the extracted files.


Change to the directory libdbi-drivers-0.9.0 in terminal.

# cd libdbi-drivers-0.9.0


In the terminal, execute the configure script present in that directory.

# ./configure --with-mysql --with-sqlite3
OPTIONS EXPLAINED

--with-mysql
Include MySQL support.

--with-sqlite3
Include SQLite3 support.

configure will check our system for required dependencies, assigns values for system-dependent variables and use these values to generate the Makefile.


Execute make.

# make

make will look at our Makefile, compile our program code and create the executables in the sequence described.


Execute make install.

# make install
OPTIONS EXPLAINED

install
install will look for the target install in Makefile.PL, and install DBD::mysql to the specified location.

make will look for the target install in Makefile, and install libdbi-drivers to /usr/local/.
Run ldconfig.
NOTE: Before running this command, make sure you have added the directory /usr/local/ to the System library path as instructed here.

# ldconfig

ldconfig scans the ld.so.conf.d directory and updates the shared library cache; so that dynamic-linker can find them during runtime.

 

 

 

After customizing MySQL Server, it is recommended to view the following section.
Basics of MySQL Server

OR

You may go directly to the following section.
Installing Apache HTTP Server