mysql 8.0编译安装

#依赖
yum install -y ncurses ncurses-devel cmake bison bison-devel openssl openssl-libs openssl-devel gcc gcc-c++ gcc-g77 make
#boost
wget http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_66_0.tar.gz
tar -zxf boost_1_66_0.tar.gz -C /usr/local/
mv boost_1_66_0 boost_1_66
#创建mysql用户
useradd -s /sbin/nologin -M mysql
#下载mysql
wget https://cdn.mysql.com//archives/mysql-8.0/mysql-boost-8.0.11.tar.gz
tar -zxf mysql-boost-8.0.11.tar.gz
cd mysql-8.0.11/
#编译
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/3306/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_BOOST=/usr/local/boost_1_66
#安装
make && make install
#创建目录
useradd -s /sbin/nologin -M mysql
mkdir -p /usr/local/mysql/data/{3306/{data,tmp,binlog,innodb_ts,innodb_log},backup,scripts}
chown -R mysql.mysql /usr/local/mysql/data/
#配置文件
vim /usr/local/mysql/data/3306/my.cnf
[client]
port = 3306
socket = /usr/local/mysql/data/3306/mysql.sock
# The MySQL server
[mysqld]
port = 3306
user = mysql
socket = /usr/local/mysql/data/3306/mysql.sock
pid-file = /usr/local/mysql/data/3306/mysql.pid
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data/3306/data
tmpdir = /usr/local/mysql/data/3306/tmp
open_files_limit = 60000
explicit_defaults_for_timestamp
server-id = 1203306
lower_case_table_names = 1
character-set-server = utf8
federated
#sql_mode=STRICT_TRANS_TABLES
max_connections = 1000
max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
sync_binlog=0
back_log=100
default-storage-engine = InnoDB
log_slave_updates = 1

#*********** Logs related settings ***********
log-bin = /usr/local/mysql/data/3306/binlog/mysql-bin
binlog_format= mixed
binlog_cache_size=32m
max_binlog_cache_size=64m
max_binlog_size=512m
long_query_time = 1
log_output = FILE
log-error = /usr/local/mysql/data/3306/mysql-error.log
slow_query_log = 1
slow_query_log_file = /usr/local/mysql/data/3306/slow_statement.log
#log_queries_not_using_indexes
general_log = 0
general_log_file = /usr/local/mysql/data/3306/general_statement.log
#expire-logs-days = 14
binlog_expire_logs_seconds = 1728000
relay-log = /usr/local/mysql/data/3306/binlog/relay-bin
relay-log-index = /usr/local/mysql/data/3306/binlog/relay-bin.index
#****** MySQL Replication New Feature*********
master-info-repository=TABLE
relay-log-info-repository=TABLE
relay-log-recovery
#*********** INNODB Specific options ***********
innodb_buffer_pool_size = 2048M
transaction-isolation=REPEATABLE-READ
innodb_buffer_pool_instances = 8
innodb_file_per_table = 1
innodb_data_home_dir = /usr/local/mysql/data/3306/innodb_ts
innodb_data_file_path = ibdata1:2048M:autoextend
innodb_thread_concurrency = 8
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_log_group_home_dir = /usr/local/mysql/data/3306/innodb_log
innodb_flush_log_at_trx_commit = 2
innodb_max_dirty_pages_pct = 70
innodb_flush_method=O_DIRECT
[mysql]
no-auto-rehash
default-character-set=gbk
prompt = (\u@\h) [\d]>\_
#初始化
/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/data/3306/my.cnf --initialize --user=mysql
#启动
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/data/3306/my.cnf --user=mysql &

#root初始密码
tail -f /usr/local/mysql/data/3306/mysql-error.log
A temporary password is generated for root@localhost: Iox)#5/Sk?o=

#修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH sha256_password BY 'zsd@7101'


#管理启动脚本
vim /usr/local/mysql/support-files/mysql.server
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
mysqld_pid_file_path=/usr/local/mysql/data/3306/mysql.pid

ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/sbin/chkconfig mysqld on

 
posted @ 2016-08-30 16:43  风儿飘  阅读(506)  评论(0编辑  收藏  举报