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


网页题目:MySQL源码安装
网页链接:http://ybzwz.com/article/jegihs.html