1.环境介绍:
包:mysql-5.6.24.tar.gz
平台:centos6.5
2.安装cmake编译工具和依赖包:
yum install cmake -y
yum install ncurses ncurses-devel -y
yum install openssl openssl-devel -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 -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EMBEDDED_SERVER=1 -DWITH_SSL=system
参数说明:
-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 = mysqlport = 53307socket = /usr/local/mysql/mysql.sockbasedir = /usr/local/mysqldatadir = /usr/local/mysql/dataopen_files_limit=10240back_log = 600 max_connections = 3000 max_connect_errors = 6000 table_open_cache = 4096external-locking = FALSE max_allowed_packet = 32M sort_buffer_size = 2M join_buffer_size = 2M thread_cache_size = 300 thread_concurrency = 8 query_cache_size = 64M query_cache_limit = 4M query_cache_min_res_unit = 2k default-storage-engine = MyISAMthread_stack = 192K transaction_isolation = READ-COMMITTED tmp_table_size = 256Mmax_heap_table_size = 256Mslow-query-log=0slow_query_log_file=/usr/local/mysql/slow-log.loglong_query_time=2log-binbinlog_cache_size = 4Mmax_binlog_cache_size = 8Mmax_binlog_size = 512Mexpire_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 = 1 myisam_recover skip-name-resolvelower_case_table_names = 1[mysqldump]quickmax_allowed_packet = 32M[mysqld_safe]log-error=/usr/local/mysql/mysql_oldboy.errpid-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