千家信息网

我写的一键安装MySQL脚本——暴力版

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,[root@xd-10-189 songlisha]# cat install_mysql.sh #!/bin/bashmysql_src=/songlisha/home/admin/mysql_da
千家信息网最后更新 2025年02月01日我写的一键安装MySQL脚本——暴力版
[root@xd-10-189 songlisha]# cat install_mysql.sh #!/bin/bashmysql_src=/songlisha/home/admin/mysql_datainstall_scr=/songlisha/usr/localrm -rf $install_scr/mysqlrm -rf $mysql_srcrm -rf /etc/my.cnfgroupadd mysqluseradd -g mysql mysqlmkdir -p $mysql_src/{binlog,innodb_log,innodb_ts,log,mydata,relaylog,sock,tmpdir}chown -R mysql.mysql $mysql_srctar zxvf $install_scr/mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz -C $install_scrmv $install_scr/mysql-5.6.34-linux-glibc2.5-x86_64 $install_scr/mysqlcat >> /etc/my.cnf < 'no-auto-rehashdefault_character_set = utf8[mysqld]user = mysqlbasedir = /songlisha/usr/local/mysqldatadir = /songlisha/home/admin/mysql_data port = 3306socket = /songlisha/home/admin/mysql_data/sock/my3307.sockevent_scheduler = 0max_allowed_packet=64M#skip-grant-tables#timeoutinteractive_timeout = 300wait_timeout = 100000#character setcharacter-set-server = utf8open_files_limit = 65535max_connections = 100max_connect_errors = 100000skip-name-resolve = 1#logslog-output=fileslow_query_log = 1slow_query_log_file = /songlisha/home/admin/mysql_data/log/slow.loglog-error = /songlisha/home/admin/mysql_data/log/error.loglog_warnings = 2pid-file = mysql.pid#log-slow-admin-statements = 1#log-queries-not-using-indexes = 1log-slow-slave-statements = 1long_query_time = 0.3#binlogbinlog_format = rowserver-id = 1273307log-bin = /songlisha/home/admin/mysql_data/binlog/mybin.logbinlog_cache_size = 4Mmax_binlog_size = 1Gmax_binlog_cache_size = 2Gsync_binlog = 0expire_logs_days = 7#relay logskip_slave_start = 1max_relay_log_size = 1Grelay_log_purge = 1relay_log_recovery = 1log_slave_updates#slave-skip-errors=1032,1053,1062tmpdir = /songlisha/home/admin/mysql_data/tmpdirexplicit_defaults_for_timestamp=1#buffers & cachetable_open_cache = 2048table_definition_cache = 2048table_open_cache = 2048max_heap_table_size = 96Msort_buffer_size = 2Mjoin_buffer_size = 2Mthread_cache_size = 256query_cache_size = 0query_cache_type = 0query_cache_limit = 256Kquery_cache_min_res_unit = 512thread_stack = 192Ktmp_table_size = 96Mkey_buffer_size = 8Mread_buffer_size = 2Mread_rnd_buffer_size = 16Mbulk_insert_buffer_size = 32M#myisammyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 1Gmyisam_repair_threads = 1#innodbinnodb_data_home_dir=/songlisha/home/admin/mysql_data/innodb_tsinnodb_log_group_home_dir=/songlisha/home/admin/mysql_data/innodb_loginnodb_buffer_pool_size = 1Ginnodb_buffer_pool_instances = 1innodb_data_file_path = ibdata1:10G:autoextendinnodb_flush_log_at_trx_commit = 2innodb_log_file_size = 500Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 70innodb_file_per_table = 1innodb_rollback_on_timeoutinnodb_status_file = 1transaction_isolation = READ-COMMITTEDinnodb_log_buffer_size = 16Minnodb_lock_wait_timeout = 10innodb_sync_spin_loops = 40innodb_support_xa = 0innodb_thread_concurrency = 0innodb_thread_sleep_delay = 500#innodb_file_io_threads    = 4innodb_concurrency_tickets = 1000log_bin_trust_function_creators = 1innodb_flush_method = O_DIRECTinnodb_read_io_threads = 16innodb_write_io_threads = 16innodb_io_capacity = 2000innodb_file_format = Barracudainnodb_purge_threads=1innodb_purge_batch_size = 32innodb_old_blocks_pct=75innodb_change_buffering=allinnodb_stats_on_metadata=OFF[mysqld_safe]open_file_limit = 65535EOF$install_scr/mysql/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --datadir=/songlisha/home/admin/mysql_data --basedir=/songlisha/usr/local/mysqlcp $install_scr/mysql/support-files/mysql.server /etc/init.d/mysqldservice mysqld startchkconfig mysqld onecho "export PATH="\$PATH:/songlisha/usr/local/mysql/bin"" >> /etc/profileexport PATH="/songlisha/usr/local/mysql/bin:$PATH"source /etc/profileexit 0

0