下载软件包****解压
tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/mysql
创建相关目录
mkdir /home/storage/mysql_3306/data logs run tmp
创建用户
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
修改属组用户
chown -R mysql:mysql /home/storage/mysql_3306/
编辑配置文件
didi erp mysql配置文件
vim /home/storage/mysql_3306/mysql_3306.cnf
[client]
port = 3306
socket = /home/storage/mysql_3306/run/mysql.sock
The MySQL server
[mysqld]
#########Basic##################
explicit_defaults_for_timestamp=true
port = 3306
user = mysql
basedir = /usr/local/mysql
datadir = /home/storage/mysql_3306/data
tmpdir = /home/storage/mysql_3306/tmp
pid-file = /home/storage/mysql_3306/run/mysql.pid
socket = /home/storage/mysql_3306/run/mysql.sock
#skip-grant-tables
#character set
character_set_server = utf8mb4
open_files_limit = 65535
back_log = 500
#event_scheduler = ON
lower_case_table_names=1
log_timestamps = 1
skip-external-locking
#skip_name_resolve = 1
#skip-networking = 1
default-storage-engine = InnoDB
#timeout
wait_timeout=28800
lock_wait_timeout=3600
interactive_timeout=28800
connect_timeout = 20
server-id = 18493306
#plugin
#plugin-load="semisync_master.so;semisync_slave.so"
#########SSL#############
#ssl-ca = /home/storage/mysql_3306/data/ca.pem
#ssl-cert = /home/storage/mysql_3306/data/server-cert.pem
#ssl-key = /home/storage/mysql_3306/data/server-key.pem
#########undo#############
innodb_undo_logs =126
innodb_undo_directory =/home/storage/mysql_3306/logs/
innodb_max_undo_log_size = 1G
innodb_undo_tablespaces = 8
innodb_undo_log_truncate = 1
innodb_purge_rseg_truncate_frequency = 128
#########error log#############
log-error = /home/storage/mysql_3306/logs/error.log
log_error_verbosity = 3
#########general log#############
general_log_file=/home/storage/mysql_3306/logs/general.log
#########slow log#############
slow_query_log = 1
long_query_time=1
slow_query_log_file = /home/storage/mysql_3306/logs/mysql.slow
############# for replication###################
log-bin = /home/storage/mysql_3306/logs/mysql-bin
binlog_format = ROW
max_binlog_size = 1024M
binlog_cache_size = 5M
max_binlog_cache_size = 5000M
expire-logs-days = 7
slave-net-timeout=30
log-slow-slave-statements =1
log_bin_trust_function_creators = 1
log-slave-updates = 1
#skip-slave-start = 1
#super_read_only =1
#relay log
relay-log = /home/storage/mysql_3306/logs/mysql-relay
relay-log-index=/home/storage/mysql_3306/logs/relay-bin.index
max-relay-log-size = 1024M
relay_log_purge = 1
sync_master_info = 1
sync_relay_log_info = 1
sync_relay_log = 1
relay_log_recovery = 1
#semisync
#rpl_semi_sync_master_enabled = 1
#rpl_semi_sync_master_wait_no_slave = 1
#rpl_semi_sync_master_timeout = 1000
#rpl_semi_sync_slave_enabled = 1
#rpl_semi_sync_master_timeout = 100000000
#rpl_semi_sync_master_wait_point = 'after_sync'
#rpl_semi_sync_master_wait_for_slave_count = 2
#ignore
#replicate-ignore-db = 'db,'db1'
#replicate-do-db = 'db','db1'
#replicate-do-table = 'db.t'
#replicate-ignore-table= 'db.t'
#Multi-threaded Slave
slave_parallel_workers=8
slave-parallel-type=LOGICAL_CLOCK
master_info_repository=TABLE
relay_log_info_repository=TABLE
slave_pending_jobs_size_max=200000000
#binlog_group_commit_sync_delay=1000 #binlog组提交延迟时间
#binlog_group_commit_sync_no_delay_count =100 #等待延迟提交的最大事务数
#slave_preserve_commit_order=1
GTID setting
gtid-mode = ON
enforce-gtid-consistency = true
sync-master-info = 1
slave-parallel-workers = 8
binlog-checksum = CRC32
master-verify-checksum = 1
slave-sql-verify-checksum = 1
binlog-rows-query-log_events = 1
#slave-skip-errors=1007,1051,1062
#######per_thread_buffers#####################
max_connections=3000
max_user_connections=2000
max_connect_errors=1000000
#myisam_recover
max_allowed_packet = 128M
table_open_cache = 6144
table_definition_cache = 6144
table_open_cache_instances = 64
read_buffer_size = 1M
join_buffer_size = 4M
read_rnd_buffer_size = 1M
#myisam
sort_buffer_size = 128K
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
key_buffer_size = 64M
myisam_sort_buffer_size = 32M
tmp_table_size = 64M
max_heap_table_size = 64M
query_cache_type=0
query_cache_size = 0
bulk_insert_buffer_size = 32M
thread_cache_size = 64
#thread_concurrency = 32
thread_stack = 192K
###############InnoDB###########################
innodb_data_home_dir = /home/storage/mysql_3306/data
innodb_log_group_home_dir = /home/storage/mysql_3306/logs
innodb_data_file_path = ibdata1:1000M:autoextend
innodb_temp_data_file_path = ibtmp1:12M:autoextend
innodb_buffer_pool_size = 10G
innodb_buffer_pool_instances = 8
innodb_log_file_size = 120M
innodb_log_buffer_size = 16M
innodb_log_files_in_group = 3
innodb_flush_log_at_trx_commit = 2
sync_binlog = 1
innodb_lock_wait_timeout = 10
innodb_sync_spin_loops = 40
innodb_max_dirty_pages_pct = 80
innodb_support_xa = 1
innodb_thread_concurrency = 0
innodb_thread_sleep_delay = 500
innodb_concurrency_tickets = 1000
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 1000
innodb_flush_neighbors = 1
innodb_purge_threads=2
innodb_purge_batch_size = 32
innodb_old_blocks_pct=75
innodb_change_buffering=all
innodb_stats_on_metadata=OFF
innodb_print_all_deadlocks = 1
performance_schema=1
transaction_isolation = READ-COMMITTED
#innodb_force_recovery=0
#innodb_fast_shutdown=1
#innodb_status_output=1
#innodb_status_output_locks=1
#innodb_status_file = 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
[mysqldump]
quick
max_allowed_packet = 128M
[mysql]
no-auto-rehash
max_allowed_packet = 128M
prompt = '\u@\h:\p [\d]> '
default_character_set = utf8
[myisamchk]
key_buffer_size = 64M
sort_buffer_size = 512k
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
#malloc-lib= /usr/lib/libjemalloc.so
初始化
生成系统库日志文件等
/usr/local/mysql/bin/mysqld --defaults-file=/home/storage/mysql_3306/mysql_3306.cnf --initialize-insecure --user=mysql
2022-11-29T16:44:07.961987+08:00 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
--initialize-insecure 参数作用 root没有密码
启动
启动实例可以对外提供服务了
/usr/local/mysql/bin/mysqld_safe --defaults-file=/home/storage/mysql_3306/mysql_3306.cnf --user=mysql &
版权归原作者 2301_76957510 所有, 如有侵权,请联系我们删除。