码迷,mamicode.com
首页 > 数据库 > 详细

centos6.7下 编译安装MySQL5.7

时间:2016-03-11 10:26:24      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:

centos6.7下编译安装MySQL5.7

准备工作

#-----依赖包及MySQL和boost安装包-----

#yum包安装:
shell> yum -y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison  

#获取boost类库(5.7编译需要boost类库,编译时指定boost路径):
shell> wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz   

#获取MySQL5.7 
shell> wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.9.tar.gz

 

#-----创建MySQL用户及相关目录-----

shell> groupadd mysql #创建MySQL组
shell> useradd -g501 mysql #创建MySQL用户
shell> mkdir -p /data/mysql #创建MySQL安装目录
shell> mkdir /data/mysqlData #创建MySQL数据库文件存放目录
shell> chown -R mysql:mysql /data/mysql /data/mysqlData

#-----Cmake-----

shell> tar -zxvf ./mysql-5.7.9.tar.gz
shell> cd ./mysql-5.7.9
shell> cmake -DCMAKE_INSTALL_PREFIX=/data/mysql -DSYSCONFDIR=/data/mysql/ -DMYSQL_DATADIR=/data/mysqlData/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_BOOST=/usr/local/boost
shell> make -j `grep processor /proc/cpuinfo | wc -l`
shell> make install
*比较耗系统资源 配置低编译可能会很慢*

#初始化数据库

#创建配置文件 根据实际使用情况修改 仅供参考
cat > /data/mysql/my.cnf << EOF
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4
 
[mysqld]
port = 3306
socket = /tmp/mysql.sock
 
basedir = /data/mysql
datadir = /data/mysqlData
pid-file = /data/mysqlData/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
 
init-connect = SET NAMES utf8mb4
character-set-server = utf8mb4
 
#skip-name-resolve
#skip-networking
back_log = 300
 
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
 
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
 
thread_cache_size = 8
 
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
 
ft_min_word_len = 4
 
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
 
log_error = /data/mysqlData/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysqlData/mysql-slow.log
 
performance_schema = 0
explicit_defaults_for_timestamp
 
#lower_case_table_names = 1
 
skip-external-locking
 
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
 
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
 
interactive_timeout = 28800
wait_timeout = 28800
 
[mysqldump]
quick
max_allowed_packet = 16M
 
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
EOF
#生成系统表
shell> /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
shell> service mysqld start
*注*:
1. 之前版本mysql_install_db是在mysql_basedir/script下,5.7放在了mysql_install_db/bin目录下,且已被废弃,使用--initialize-insecure。
2. –-initialize会生成一个随机密码(~/.mysql_secret),--initialize-insecure不会生成密码

#-----设置环境变量,加入开机启动-----

shell> echo export PATH=$PATH:/data/mysql/bin/ >> /etc/profile
shell> source /etc/profile
chkconfig --add myslqd
chkconfig mysqld on

#-----配置mysql的root密码-----

shell> mysql
mysql> set password for root@localhost = password(qwerasdfzxcv);
mysql> flush privileges;

centos6.7下 编译安装MySQL5.7

标签:

原文地址:http://www.cnblogs.com/youn/p/5264282.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!