1.环境介绍:
包:mysql-5.6.24.tar.gz
平台:centos6.5
2.安装cmake编译工具和依赖包:
yum install cmake -y
yum install ncurses-y
yum install bison-y
yum install gcc-c++ -y
yum install gcc-y
3.创建mysql用户:
useradd mysql -s /sbin/nologin
4.安装编译mysql
a.进入mysql安装目录
b.cmake编译:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/lib/mysql -DSYSCONFDIR=/etc -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DMYSQL_USER=mysql
参数说明:
-DCMAKE_INSTALL_PREFIX:指定mysql主目录
-DMYSQL_DATADIR:指定数据文件存放位置
-DSYSCONFDIR:指定my.cnf路径
-DMYSQL_UNIX_ADDR:指定连接数据库socket文件路径
-DENABLED_LOCAL_INFILE=1:允许从本地导入数据
-DEXTRA_CHARSETS=all:安装所有的字符集
-DDEFAULT_CHARSET=utf8:指定默认字符
-DWITH_PARTITION_STORAGE_ENGINE=1:安装支持数据库分区
c.gmake
d.make install
5.cp相关文件和修改参数:
a.拷贝
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
cp/usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
b.修改参数(创建目录:mkdir /var/lib/mysql):
[client]
port= 53307socket= /usr/local/mysql/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user=mysql
port= 53307socket= /usr/local/mysql/mysql.sock
basedir= /usr/local/mysql
datadir= /usr/local/mysql/data
open_files_limit=10240back_log= 600max_connections= 3000max_connect_errors= 6000table_open_cache= 4096external-locking =FALSE
max_allowed_packet=32M
sort_buffer_size=2M
join_buffer_size=2M
thread_cache_size= 300thread_concurrency= 8query_cache_size=64M
query_cache_limit=4M
query_cache_min_res_unit=2kdefault-storage-engine =MyISAM
thread_stack=192K
transaction_isolation= READ-COMMITTED
tmp_table_size=256M
max_heap_table_size=256M
slow-query-log=0slow_query_log_file=/usr/local/mysql/slow-log.log
long_query_time=2log-bin
binlog_cache_size=4M
max_binlog_cache_size=8M
max_binlog_size=512M
expire_logs_days= 7key_buffer_size=2048M
read_buffer_size=1M
read_rnd_buffer_size=16M
bulk_insert_buffer_size=64M
myisam_sort_buffer_size=128M
myisam_max_sort_file_size=10G
myisam_repair_threads= 1myisam_recover
skip-name-resolve
lower_case_table_names= 1[mysqldump]
quick
max_allowed_packet=32M
[mysqld_safe]
log-error=/usr/local/mysql/mysql_oldboy.err
pid-file=/usr/local/mysql/mysqld.pid
6.修改环境变量:
vim .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
7.运行mysql_install_db文件:
./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/var/lib/mysql/ --no-default --user=mysql
8.启动mysql服务:
service mysql start
9.查看mysql进程:
ps –ef|grep mysql
原文:http://www.cnblogs.com/vijayfly/p/5054927.html