MySQL5.7安装
Posted 750657961
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL5.7安装相关的知识,希望对你有一定的参考价值。
安装MySQL5.7:
安装准备阶段:
yum -y groupinstall "Development tools"
yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make
useradd mysql -s /sbin/nologin
mkdir -pv /data/mysql3306/log
chown mysql:mysql /data/mysql
tar xvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.12-linux-glibc2.5-x86_64 /usr/local/mysql
chown -R mysql: /usr/local/mysql
初始化:
cd /usr/local/mysql/
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
#[email protected]: =,B-glo2tV& #屏幕输出密码
#如果/etc/my.cnf 设置了放在文件那么屏幕就不会输出密码了,可能会输出到错误日志里面
初始化后续:
cp support-files/mysql.server /etc/init.d/mysql5.7
vim /etc/init.d/mysql5.7
#basedir=/usr/local/mysql
#datadir=/data/mysql
vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin/
/etc/init.d/mysql5.7 start
mysql -uroot -p"=,B-glo2tV&T"
alter user ‘root‘@‘localhost‘ identified by ‘123456‘;
my.cnf 参考配置文件:(配置文件仅供参考)
#mysql5.7.9
[client]
port = 3306
socket = /tmp/mysql3306.sock
default_character_set = utf8mb4
[mysqld]
lower_case_table_names = 1
port = 3306
basedir = /usr/local/mysql
datadir = /data/mysql3306/mysql3306
socket = /tmp/mysql3306.sock
pid_file = /data/mysql3306/mysql3306.pid
tmpdir = /tmp/
skip_name_resolve = 1
character_set_server = utf8
collation_server = utf8_unicode_ci
max_connections = 512
max_connect_errors = 100000
interactive_timeout = 600
wait_timeout = 600
table_open_cache = 2048
query_cache_type = 0
#query_cache_size = 64M
#query_cache_limit = 2M
thread_cache_size = 51
max_allowed_packet = 16M
tmp_table_size = 256M
max_tmp_tables = 128
max_heap_table_size = 96M
sort_buffer_size = 4M
read_buffer_size = 4M #顺序IO
join_buffer_size = 4M
read_rnd_buffer_size = 8M #随机IO
bulk_insert_buffer_size = 64M #
default_storage_engine = InnoDB
log_bin = /data/mysql3306/mysql3306/mysql-bin
expire_logs_days = 7
binlog_format = row
log_slave_updates =1
log_error = /data/mysql3306/logs/mysql-error.log
slow_query_log = 1
slow_query_log_file = /data/mysql3306/logs/mysql-slow.log
long_query_time = 1
log_output = FILE
log_queries_not_using_indexes = 1
relay_log = /data/mysql3306/mysql3306/mysql-relay
max_binlog_cache_size = 8M
max_binlog_size = 1024M
binlog_cache_size = 4M
sync_binlog = 1
server_id = 15133306
#innodb
innodb_data_home_dir = /data/mysql3306/mysql3306/
innodb_data_file_path = ibdata1:512M:autoextend
innodb_log_group_home_dir = /data/mysql3306/mysql3306
innodb_buffer_pool_instances = 1
innodb_buffer_pool_size = 1024M
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 4
innodb_log_file_size = 256M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 32M #default 16M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 30
innodb_undo_directory = /data/mysql3306/mysql3306/
innodb_undo_logs = 128 #must >=35.default 128
innodb_undo_tablespaces = 3 #must >=2
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 1000M
innodb_purge_rseg_truncate_frequency = 128
innodb_print_all_deadlocks = 1
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_open_files = 65536
innodb_file_per_table = 1
innodb_lock_wait_timeout = 30
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_io_capacity = 200
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
innodb_purge_threads = 4
innodb_support_xa = 1
innodb_max_dirty_pages_pct = 75
transaction_isolation = REPEATABLE-READ
#rep
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=16
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
binlog_checksum=NONE
slave_preserve_commit_order=1
#group_replication_flow_control_mode=DISABLED
gtid_mode=on
log_slave_updates=1
enforce_gtid_consistency=1
#GR
transaction_write_set_extraction =XXHASH64 # off
loose-group_replication_group_name ="a876d35e-9110-11e6-a365-842b2b5909d6" #
loose-group_replication_start_on_boot =off # off
loose-group_replication_local_address ="192.168.31.200:24900" #
loose-group_replication_group_seeds ="192.168.31.200:24900,192.168.31.201:24900,192.168.31.202:24900"
loose-group_replication_bootstrap_group =off # off
[mysqldump]
max_allowed_packet = 16M
[mysql]
default_character_set = utf8
以上是关于MySQL5.7安装的主要内容,如果未能解决你的问题,请参考以下文章