How to install MySQL 5.7 on CentOS 7.3

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了How to install MySQL 5.7 on CentOS 7.3相关的知识,希望对你有一定的参考价值。

mkdir -p /home/tools
cd /home/tools
yum -y install numactl libaio
wget http://god.nongdingbang.net/downloads/mysql-5.7-el7.tgz && tar zxvf mysql-5.7-el7.tgz
rpm -Uvh *rpm
mkdir -p /data/{mysql_data,mysql_log,mysql_slow,mysql_undo}
chown -R mysql.mysql /data/*
cat >/etc/my.cnf<<EOF
[client]
port=3306
socket=/tmp/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
port=3306
character-set-server=utf8
socket=/tmp/mysql.sock
datadir=/data/mysql_data
explicit_defaults_for_timestamp=true
lower_case_table_names=1
sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘
back_log=103
max_connections=3000
max_connect_errors=100000
table_open_cache=512
external-locking=FALSE
max_allowed_packet=32M
sort_buffer_size=2M
join_buffer_size=2M
thread_cache_size=51
query_cache_size=32M
#query_cache_limit=4M
transaction_isolation=REPEATABLE-READ
tmp_table_size=96M
max_heap_table_size=96M
log-error=/data/mysql_log/error.log
###***slowqueryparameters
long_query_time=2
slow_query_log=1
slow_query_log_file=/data/mysql_slow/slow.log
###***binlogparameters
log-bin=mysql-bin
binlog_cache_size=4M
max_binlog_cache_size=4096M
max_binlog_size=1024M
binlog_format=ROW
binlog_row_image=minimal
expire_logs_days=3
sync_binlog=0
###***undolog
innodb_undo_directory=/data/mysql_undo
innodb_undo_logs=128
innodb_undo_tablespaces=4
innodb_undo_log_truncate=1
innodb_max_undo_log_size=1G
innodb_purge_rseg_truncate_frequency
#***MyISAMparameters
key_buffer_size=16M
read_buffer_size=1M
read_rnd_buffer_size=16M
bulk_insert_buffer_size=1M
###***master-slavereplicationparameters
server-id=1
#slave-skip-errors=all
#***Innodbstorageengineparameters
innodb_buffer_pool_dump_at_shutdown=1
innodb_buffer_pool_load_at_startup=1
innodb_buffer_pool_size=16G
innodb_data_file_path=ibdata1:10M:autoextend
#innodb_file_io_threads=8
innodb_thread_concurrency=0
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=16M
innodb_log_file_size=512M
innodb_log_files_in_group=2
innodb_max_dirty_pages_pct=75
innodb_buffer_pool_dump_pct=50
innodb_lock_wait_timeout=50
innodb_file_per_table=on
innodb_flush_neighbors=1
innodb_io_capacity_max = 2000
wait_timeout = 14400
interactive_timeout = 14400
[mysqldump]
quick
max_allowed_packet=32M
 
[myisamchk]
key_buffer=16M
sort_buffer_size=16M
read_buffer=8M
write_buffer=8M
 
[mysqld_safe]
open-files-limit=8192
log-error=/data/mysql_log/error.log
pid-file=/data/mysql_data/mysqld.pid
EOF

## Initialize MySQL configuration
mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql_data --initialize-insecure

## Start mysql
systemctl restart mysqld && systemctl enable mysqld

## Setting root‘s password for mysql
##############################################
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘[email protected]‘;
mysql> select user,host,authentication_string,password_expired from user;

本文出自 “运维人生” 博客,请务必保留此出处http://jinyan2049.blog.51cto.com/881440/1948463

以上是关于How to install MySQL 5.7 on CentOS 7.3的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu——How to Install MySQL GUI

How to Install Nginx with PHP + MySQL (LEMP) on Debian 9

How to install MySQL on CentOS

How to Install MySQL on CentOS 7

How To Install MySQL on Ubuntu 16.04

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu