Thursday, January 9, 2014

MySQL 5.6 source compiled installation on linux

Here I will explain how to install MySQL 5.6 server under Debian based system.

First install proper compilers and dependencies.

apt-get install gcc g++ make bison libncurses5-dev

Download cmake,
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz

tar -zxvf cmake-2.8.12.1.tar.gz
cd cmake-2.8.12.1

./configure
make
make install

Now, download latest MySQL 5.6 package,

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz

create users and group,
groupadd mysql
useradd -g mysql -d /var/mysql -s /bin/bash -m mysql

mkdir /var/mysql/src/

mv mysql-5.6.15.tar.gz /var/mysql/src/

chown mysql.mysql /var/mysql/src/ -R

su - mysql

cd src/

tar -zxvf mysql-5.6.15.tar.gz
cd mysql-5.6.15

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/ -DMYSQL_DATADIR=/var/mysql/data -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_MAINTAINER_MODE=OFF -DWITH_DEBUG=OFF

make

su (For running make install as root)

make install

cp -vf /var/mysql/src/mysql-5.6.15/support-files/my-default.cnf /etc/my.cnf

vim /etc/my.cnf (sample configuration)

[client]
port            = 3306
socket          = /tmp/mysql.sock

# The MySQL server
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size         = 64M
max_allowed_packet      = 16M
table_open_cache        = 64
sort_buffer_size        = 8M
net_buffer_length       = 8K
read_buffer_size        = 2M
read_rnd_buffer_size    = 4M
myisam_sort_buffer_size = 8M
query_cache_size        = 256M
join_buffer_size        = 2M
tmp_table_size          = 160M
max_heap_table_size     = 160M
thread_cache_size       = 4
thread_concurrency      = 4
query_cache_limit       = 48M

#slow_query_log
#log_queries_not_using_indexes

sql_mode=TRADITIONAL
bind-address = 0.0.0.0
server-id       = 1

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /var/mysql/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/mysql/data
innodb_buffer_pool_size = 1500M  # 60-70 % of ram for dedicated database.
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
innodb_open_files = 500
innodb_flush_method = O_DIRECT  (For removing OS level caching, Dont use if database is at SAN. )

:wq

Now install the table structure by issuing the below command as mysql user,

/usr/local/scripts/mysql_install_db --user=mysql

Copy the init script and make it executable,

cp -vf /var/mysql/src/mysql-5.6.15/support-files/mysql.server /etc/init.d/mysqld

chmod +x  /etc/init.d/mysqld

start mysql service,

/etc/init.d/mysqld start

For any errors go through the .err file in the mysql data directory.

Thanks for reading,

Cheers/-

No comments:

Post a Comment