mysql创建

cd /paic/my${port}
在MYSQL_HOME下vi my.cnf server_id请通过右边的脚本生成
[client]                          
socket                             = /paic/my${port}/var/mysql.sock
port                               = ${port}
[mysqld]

############# GENERAL #############
autocommit                         = ON
character_set_server               = UTF8MB4
collation_server                   = UTF8MB4_bin
explicit_defaults_for_timestamp    = ON 
lower_case_table_names             = 1
port                               = ${port}
read_only                          = OFF
transaction_isolation              = READ-COMMITTED

####### CACHES AND LIMITS #########
interactive_timeout                = 600
max_allowed_packet                 = 32M
max_connect_errors                 = 10000
max_connections                    = 500
max_user_connections               = 400
sort_buffer_size                   = 1M
table_definition_cache             = 1400
table_open_cache                   = 2000
table_open_cache_instances         = 4
thread_cache_size                  = 9
thread_stack                       = 256K
tmp_table_size                     = 32M

############# SAFETY ##############
local_infile                       = OFF
skip_name_resolve                  = ON
sql_mode                           = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY

############# LOGGING #############
general_log                        = 0
log_queries_not_using_indexes      = ON
log_slow_admin_statements          = ON
log_warnings                       = 2
long_query_time                    = 1
slow_query_log                     = ON

############# REPLICATION #############
binlog_checksum                    = CRC32
binlog_format                      = row
binlog_rows_query_log_events       = ON
enforce_gtid_consistency           = ON
expire_logs_days                   = 7
gtid_mode                          = ON
log_slave_updates                  = ON
master_info_repository             = TABLE
master_verify_checksum             = ON
max_binlog_size                    = 256M
relay_log_info_repository          = TABLE
server_id                          = ${server_id}
skip_slave_start                   = ON
slave_net_timeout                  = 4
slave_sql_verify_checksum          = ON
sync_binlog                        = 0
sync_master_info                   = 10000
sync_relay_log                     = 10000
sync_relay_log_info                = 10000


############### PATH ##############
basedir                            = /paic/mysql/base

datadir                            = /paic/my${port}/data
tmpdir                             = /paic/my${port}/tmp
socket                             = /paic/my${port}/var/mysql.sock
pid_file                           = /paic/my${port}/var/mysql.pid
innodb_data_home_dir               = /paic/my${port}/data

log_error                          = /paic/my${port}/log/error.log
general_log_file                   = /paic/my${port}/log/general.log
slow_query_log_file                = /paic/my${port}/log/slow.log

log_bin                            = /paic/my${port}/log/mysql-bin
log_bin_index                      = /paic/my${port}/log/mysql-bin.index
relay_log                          = /paic/my${port}/log/relay-log
relay_log_index                    = /paic/my${port}/log/relay-log.index

############# INNODB #############
innodb_file_format                 = barracuda
innodb_flush_method                = O_DIRECT
innodb_buffer_pool_size            = 2G
innodb_log_file_size               = 256M
innodb_log_files_in_group          = 4
innodb_flush_log_at_trx_commit     = 2
innodb_support_xa                  = ON
innodb_strict_mode                 = ON
innodb_data_file_path              = ibdata1:256M;ibdata2:16M:autoextend
innodb_checksum_algorithm          = strict_crc32

[mysql]
############# CLIENT #############                           
max_allowed_packet                 = 32M
socket                             = /paic/my${port}/var/mysql.sock
[mysqldump]                       

max_allowed_packet                 = 32M


cd $MYSQL_HOME
scripts/mysql_install_db --defaults-file=/paic/my${port}/my.cnf
cd $MYSQL_HOME
mysqld_safe  --defaults-file=/paic/my${port}/my.cnf &
mysql -uroot --socket=/paic/my${port}/var/mysql.sock
ln -s /paic/my${port}/var/mysql.sock /tmp/mysql.sock
mysql_secure_installation --defaults-file=/paic/my${port}/my.cnf
脚本执行请按下面选项进行安全初始化
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
All done! 
rm /tmp/mysql.sock
mysql_config_editor set --login-path=root --user=root --password
输入root的密码
验证login文件无需输入密码登录即可
mysql --login-path=root --socket=/paic/my${port}/var/mysql.sock

停库
mysqladmin -uroot -p --socket=/paic/my${port}/var/mysql.sock shutdown
起库
mysqld_safe  --defaults-file=/paic/my${port}/my.cnf &
验证参数autocommit
show variables like '%autocommit%';

你可能感兴趣的:(mysql创建)