mysql-5.7.20 linux_centos7部署mysql-5.7.20

1.创建目录及用户

useradd mysql -s /sbin/nologin -M

mkdir /tools

mkdir /usr/local/mysql-5.7.20/{conf,tmp} -p

mkdir /data/mysql-5.7.20/data -p

2.下载软件

cd /tools

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.20.tar.gz

tar xf mysql-boost-5.7.20.tar.gz

cd mysql-5.7.20

3.下载依赖

yum -y install gcc gcc-devel gcc-c++ gcc-c++-devel autoconf* automake* zlib* libxml* ncurses-devel

yum -y install ncurses libgcrypt* libtool* cmake openssl openssl-devel bison bison-devel

yum -y install imake perl-Data-Dumper libaio-devel boost boost-doc boost-devel

yum -y install ncurses5-devel libxml2-devel expat-devel libaio bzr

4.编译

cmake . \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.20 \

-DSYSCONFDIR=/usr/local/mysql-5.7.20/conf \

-DMYSQL_DATADIR=/data/mysql-5.7.20/data \

-DDOWNLOAD_BOOST=1 \

-DWITH_BOOST=/tools/mysql-5.7.20/boost/boost_1_59_0 \

-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.7.20/tmp/mysql.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DEXTRA_CHARSETS=all \

-DENABLE_DOWNLOADS=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_ZLIB:STRING=1 \

-DENABLE_DTRACE=0 \

-DDEFAULT_CHARSET=utf8mb4 \

-DDEFAULT_COLLATION=utf8mb4_general_ci \

-DWITH_EMBEDDED_SERVER=1 \

#如果编译错误,有一个编译缓存文件需要删除

rm -f CMakeCache.txt

5.安装

make && make install

6.软连接

ln -s /usr/local/mysql-5.7.20 /usr/local/mysql

7.配置文件

cat >>/etc/my.cnf<

[client]

#password = your_password

port = 3306

socket = /tmp/mysqld.sock

[mysqld]

port = 3306

basedir = /usr/local/mysql

datadir = /data/mysql/data/

socket = /tmp/mysqld.sock

character-set-server = UTF8

default-storage-engine = InnoDB

lower_case_table_names = 1

user = mysql

open_files_limit = 102400

#sql-mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

#explicit_defaults_for_timestamp = true

symbolic-links = 0

skip-external-locking

skip-slave-start

#============================= Network ===============================

back_log = 50

max_connections = 800

max_user_connections = 0

max_connect_errors = 999999999

net_buffer_length = 8K

max_allowed_packet = 64M

wait_timeout = 388000

interactive_timeout = 388000

#max_long_data_size = 1024M

#========================== Session Thread ===========================

thread_cache_size = 128

thread_stack = 512K

#thread_concurrency = 4

#============================ Table Cache ============================

#table-cache = 512

table_open_cache = 512

join_buffer_size = 16M

sort_buffer_size = 16M

query_cache_type = OFF

table_definition_cache = 768

#============================= Temptable =============================

tmp_table_size = 128M

max_heap_table_size = 128M

tmpdir = /data/mysql/tmp/

#======================= Query Specific options ======================

#query_cache_limit = 32M

query_cache_min_res_unit = 4096

query_cache_size = 0

#query_cache_strip_comments = 0

query_cache_type = 1

query_cache_wlock_invalidate = 0

#====================== MyISAM Specific options ======================

read_buffer_size = 2M

read_rnd_buffer_size = 16M

key_buffer_size = 512M

myisam_sort_buffer_size = 256M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

#myisam_recover_options

#====================== INNODB Specific options ======================

innodb_data_home_dir = /data/mysql/data/

innodb_fast_shutdown = 1

innodb_force_recovery = 0

innodb_buffer_pool_size = 512M

innodb_log_buffer_size = 64M

innodb_log_file_size = 512M

innodb_log_files_in_group = 2

innodb_data_file_path = ibdata1:100M:autoextend

innodb_file_format = Antelope

innodb_file_per_table = 1

innodb_write_io_threads = 8

innodb_read_io_threads = 8

innodb_io_capacity = 200

innodb_open_files = 1024

innodb_purge_threads = 1

innodb_thread_concurrency = 34

innodb_flush_log_at_trx_commit = 2

innodb_flush_method = O_DIRECT

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 1000

#innodb_additional_mem_pool_size = 67108864

innodb_strict_mode = 1

innodb_use_native_aio = 1

#innodb_status_file = 1

#================================ Log ================================

log-error = /data/mysql/log/error.log

#log-warnings

#skip-log-warnings

#general-log = 1

#general_log_file = /data/mysql/log/general.log

#slow-query-log

#slow_query_log_file = /data/mysql/log/slow.log

#long_query_time = 60

#log-queries-not-using-indexes

#==================== Replication related settings ===================

server-id = 156

#replicate-do-db =

#replicate-wild-do-table =

#replicate-ignore-db =

#replicate-ignore-table =

#replicate-wild-ignore-table =

#binlog_format MIXED

#binlog_cache_size = 32K

#max_binlog_size = 512M

#sync_binlog = 0

#innodb_support_xa = 1

#log-bin = mysql-bin

#log-bin-index = mysql-bin.index

#relay-log = mysql-relay-bin

#relay-log-index = mysql-relay-bin.index

#expire_logs_days = 10

#log_slave_updates = 1

#relay-log-purge = 1

#slave-skip-errors=1146,1062,1050,1054,1136,1364,1051

#skip-slave-start

[mysqld_safe]

log-error = /data/mysql/log/mysqld_safe.log

pid-file=/data/mysql/mysqld.pid

[mysqldump]

quick

max_allowed_packet = 1024M

[mysql]

no-auto-rehash

#Remove the next comment character if you are not familiar with SQL

#safe-updates

default-character-set = utf8

[myisamchk]

key_buffer_size = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

EOF

8.创建pid文件修改属主

mkdir /data/mysql/{data,tmp,log}

touch /data/mysql/mysqld.pid

chown -R mysql:mysql /data/mysql

9.初始化启动

#初始化

/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

#启动服务

/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &

#查看初始密码登陆mysql(这个日志中记录了初始密码)

cat /data/mysql/log/error.log

mysql -uroot -p

密码:

mysql> set password for root@localhost = PASSWORD('123456');

mysql> flush privileges;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值