1)下载
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-el7-x86_64.tar.gz
2)创建用户
groupadd mysql
useradd mysql -g mysql
3)创建目录
mkdir -p /data/mysql/data
mkdir -p /data/mysql/tmp
mkdir -p /data/mysql/log
mkdir -p /data/mysql/bin-logs
mkdir -p /data/servers
4)上传文件到/export,解压
tar zxvf mysql-8.0.11-el7-x86_64.tar.gz
mv mysql* /data/servers/mysql
5)修改组
chown -R mysql:mysql /export/*
6)创建配制文件
vi /data/servers/mysql/etc/my.cnf
[client]
port = 3306
socket = /data/mysql/tmp/mysql3306.sock
[mysql]
prompt = mysql [\d]>
default_character_set = utf8
no-auto-rehash
[mysqld]
#misc
user = mysql
basedir = /data/servers/mysql
datadir = /data/mysql/data
port = 3306
socket = /data/mysql/tmp/mysql.sock
event_scheduler = 0
tmpdir= /data/mysql/tmp
#timeout
interactive_timeout = 43200
wait_timeout = 43200
#character set
character-set-server = utf8
open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000
#
explicit_defaults_for_timestamp
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = /data/mysql/log/slow.log
log-error = /data/mysql/log/error.log
log_error_verbosity=3
pid-file = mysql.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1
#binlog
binlog_format = row
server-id = 1343306
log-bin = /data/mysql/bin-logs/mysql-bin
binlog_cache_size = 1M
max_binlog_size = 200M
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 10
#group replication
server_id=1013306
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
log_slave_updates=ON
binlog_format=ROW
transaction_write_set_extraction=XXHASH64
#loose-group_replication_group_name="13855fca-d2ab-11e6-8f37-005056b8286c"
#loose-group_replication_start_on_boot=off
#loose-group_replication_local_address= "172.16.3.134:23306"
#loose-group_replication_group_seeds= "172.16.3.134:33061,172.16.3.134:33071,172.16.3.134:33081"
#loose-group_replication_bootstrap_group= off
#loose-group_replication_single_primary_mode=off
#loose-group_replication_enforce_update_everywhere_checks=on
#relay log
skip_slave_start = 1
max_relay_log_size = 500M
relay_log_purge = 1
relay_log_recovery = 1
#slave-skip-errors=1032,1053,1062
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
#query_cache_limit = 256K
#query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M
#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
#innodb
innodb_buffer_pool_size = 500M
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:100M:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 2000
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT
7)初始化
/data/servers/mysql/bin/mysqld --defaults-file= /data/servers/mysql/etc/my.cnf --initialize-insecure
8)启动数据库
/data/servers/mysql/bin/mysqld_safe --defaults-file= /data/servers/mysql/etc/my.cnf &
注:初始化mysql 数据库的root 密码为空
错误:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock’
解决办法
创建一软连接
ln -s /data/mysql/tmp/mysql.sock /tmp/mysql.sock