MySQL源码安装
1,下载源码安装包
http://dev.mysql.com/downloads/mysql/ Source Code
https://cmake.org/download/ 5.5后版本需用cmake编译
mysql-5.7 需要
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/data/boost_1_59_0
yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* |
CentOS7 磁盘扩容文件系统为xfs 最后LV扩容后重新识别使用xfs_growfs
2,解压安装.tar.gz
tar zxvf cmake-3.4.1.tar.gz
cd cmake-3.4.1
./configure
make
make install
tar –xvfz mysql-5.6.28.tar.gz
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARITION_STORAGE_ENGINE=1 \
-DWITH_READLINE=ON \
-DEXTRA_CHARSETS=all \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/data/3306 \
-DMYSQL_UNIX_ADDR=/data/3306/mysql.sock \
-DENABLED_LOCAL_INFILE=1
make && make install
3,建用户和目录
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
mkdir -p /usr/local/mysql/data
mkdir -p /data/{3306/{data,tmp,binlog},backup,scripts}
chown -R mysql:mysql /data
4,设置用户系统资源限制
vi /etc/security/limits.conf
mysql soft nproc 2047
mysql hard nproc 16384
mysql soft nofile 1024
mysql hard nofile 65536
5,初始化参数文件
vi /data/3306/my.cnf
[client]
port = 3306
socket = /data/3306/mysql.sock
#The MYSQL SERVER
[mysqld]
port = 3306
user = mysql
server-id = 111111
socket = /data/3306/mysql.sock
pid-file = /data/3306/mysql.pid
basedir = /usr/local/mysql
datadir = /data/3306/data
tmpdir = /data/3306/tmp
open_files_limit = 10240
explicit_defaults_for_timestamp
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#BUFFER
max_allowed_packet = 256M
max_heap_table_size = 256M
net_buffer_length = 8K
sort_buffer_size = 2M
join_buffer_size = 4M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
#log
log-bin = /data/3306/binlog/mysql-bin
binlog_cache_size = 32m
max_binlog_cache_size = 512m
max_binlog_size = 512m
binlog_format = mixed
log_output = FILE
log-error = ../mysql-error.log
slow_query_log = 1
slow_query_log_file = ../slow_query.log
general_log = 0
general_log_file = ../general_query.log
expire-logs-days = 14
#InnoDB
innodb_data_file_path = ibdata1:2048M:autoextend
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_buffer_pool_size = 1024M
[mysql]
no-auto-rehash
prompt = (\u@\h)[\d]\_
default-character-set = utf8
6,初始化MYSQL数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/3306/data
7,启动数据库服务
cp support-files/mysql.server /etc/init.d/mysql
service mysql start #若启动不成功,查看是哪个my.cnf启动的
./mysqld_safe --defaults-file=/data/3306/my.cnf
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341