MYSQL 5.6.27源码安装

1、需要安装的工具
# gcc、make、cmake
# 5.6 gcc 41, cmake 2.6.3
yum install -y gcc make cmake
2)mysql依赖包支持语法分析的bison库和终端类GUI支持ncurses
yum install -y  bison*
yum install -y ncurses*
yum install -y libaio

2、tcmalloc
### depend
# libunwind-1.1.tar.gz
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install

### tcmalloc  http://gperftools.googlecode.com/files/gperftools-2.1.tar.gz
./configure --enable-minimal --disable-cpu-profiler --disable-heap-profiler --disable-heap-checker --disable-debugalloc
make && make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig

### ERROR
# /usr/bin/ld: cannot find -ltcmalloc
ln -s /usr/local/lib/libtcmalloc_minimal.so /usr/lib/libtcmalloc.so

3、install
# 创建安装目录
mkdir /usr/local/mysql

# 清除
make clean

# 查看支持的配置项 http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
# 默认包含的引擎:MyISAM, MERGE, MEMORY, and CSV 
cmake . -LH | more

# normal
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/my5627 \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci 

# LOAD DATA INFILE, 0 disable DEFAULT, 1 enable
-DENABLED_LOCAL_INFILE=1 

# with tcmalloc
-DCMAKE_EXE_LINKER_FLAGS="-ltcmalloc" -DWITH_SAFEMALLOC=OFF

# make
#加快编译速度,使用多核并行编译,即8为计算的核的个数
make -j 8 
make install

4、 Create a mysql User and Group
groupadd mysql
# the -r option to create a user that does not have login permissions to your server host
useradd -r -g mysql mysql

5、初始化
/usr/local/mysql/my5627/scripts/mysql_install_db --no-defaults --user=mysql --basedir=/usr/local/mysql/my5627  --datadir=/usr/local/mysql/my5627/data

6、创建 /usr/local/mysql/my5627/cnf/my.cnf
[mysqld]
datadir=/usr/local/mysql/my5627/data
socket=/tmp/mysql5627.sock3306
port=3306
user=mysql

7、启动
# mysqld_safe
/usr/local/mysql/my5627/bin/mysqld_safe --defaults-file=/usr/local/mysql/my5627/cnf/my.cnf &

8、配置mysql服务
# 单实例
cp /usr/local/mysql/my5627/support-files/mysql.server /etc/init.d/mysqld5627
chkconfig --add mysqld5627
chkconfig mysqld5627 on

9、设置root密码
# 由于 mysql_secure_installation 不能设置socket,只能做个软链接
ln -s /tmp/mysql5627.sock3306 /tmp/mysql.sock
/usr/local/mysql/my5627/bin/mysql_secure_installation

### 编译到 /usr/local/mysql_5629路径
# mysqld_multi.server 修改
--
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
++
basedir=/usr/local/mysql_5629
bindir=$basedir/bin

#
--
$opt_mysqladmin    = "/usr/local/mysql_5629/bin/mysqladmin";
$opt_mysqld        = "/usr/local/mysql_5629/bin/mysqld";

++
push @defaults_options, "-s";
$opt_path          = "/usr/local/mysql_5629";
$default_file      = "$opt_path/my.cnf";
$opt_mysqladmin    = "$opt_path/bin/mysqladmin";
$opt_mysqld        = "$opt_path/bin/mysqld";


sub defaults_for_group{
--
my $com= join ' ', 'my_print_defaults',  @defaults_options, $group;
++
my $com= join ' ', 'my_print_defaults', " --defaults-file=$default_file ", @defaults_options, $group;
}

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26250550/viewspace-1824836/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26250550/viewspace-1824836/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值