MySQL编译安装

/data 文件夹放tar,rpm,zip包,解压和编译放在此文件夹下的source文件夹内

# uname -a

Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

CentOS 6.4 64位,最小化安装

基本配置

vim /etc/resolv.conf
search localdomain
nameserver 202.96.128.86
nameserver 202.96.128.166
nameserver 202.96.134.33
nameserver 8.8.8.8
                                                                                   
ulimit -HSn 65535

一、安装libmcrypt2.5.8加密算法扩展库


mkdir -p /data/source 
tar -zxvf libmcrypt-2.5.8.tar.gz -C ./source/       
cd source/libmcrypt-2.5.8/
./configure
make&& make install && /sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make&& make install
cd /data

二、安装cmake2.8.7  跨平台的安装(编译)工具

tar -zxvf cmake-2.8.7.tar.gz -C ./source/
cd source/cmake-2.8.7
./configure
make && make install
cd /data

三、安装pcre8.30  一个Perl库,包括perl兼容的正规表达式库

mkdir -p /usr/local/pcre
tar -zxvf pcre-8.30.tar.gz -C ./source/
cd source/pcre-8.30
./configure --prefix=/usr/local/pcre
make&&make install
cd /data

四、安装mysql5.5.37

#DATA_DIR=/var/mysql/data
#INSTALL_DIR=/usr/local/mysql
                                                                     
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin
mkdir -p /var/mysql/data
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /var/mysql
cd /data
tar -xzf mysql-5.5.37.tar.gz -C ./source/
cd source/mysql-5.5.37
cmake -DCMAKE_BUILD_TYPE:STRING=Release -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make
make install

复制配置文件:

mv /etc/my.cnf /etc/my.cnf.bak
cp ./support-files/my-huge.cnf /etc/my.cnf
vim /etc/my.cnf
在[client]下添加:
default-character-set=utf8
在[mysqld]添加:
datadir = /var/mysql/data
skip-name-resolve
lower_case_table_names = 1
character-set-server = utf8
log-error = /var/mysql/mysql-error.log
pid-file = /var/mysql/data/mysql.pid

复制启动脚本

cp ./support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

初始化数据库

cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql  --datadir=/var/mysql/data

启动数据库

service mysqld restart
Starting MySQL......                  [  OK  ]

更改mysql的连接数

set global max_connections=10000;
show variables like ‘%max_connections%‘;

记录操作历史

general_log=1    # 将日志记录到mysql的table中
log_output=TABLE
select * from mysql.general_log;   #查看历史


清除MySQL的安装

rm -fR /etc/my.*
rm -fR /usr/local/mysql
rm -fR /var/mysql
find / -name mysql*


本文出自 “一颗石头 BBOTTE的博客” 博客,请务必保留此出处http://bbotte.blog.51cto.com/6205307/1390872

MySQL编译安装,布布扣,bubuko.com

MySQL编译安装

上一篇:mysql单机多实例--源码安装—方法2


下一篇:CentOS 6.5 编译安装 mysql 5.6.17