MySQL init script and configuration

一个简单脚本init-mysql.sh,用于初始化刚安装MySQL, 更改数据库的存入目录至/adm/mysql, 包括创建必要的目录,删除不需要的目录,设置root初始密码,删除anonymous用户,删除无用的数据库test, 不允许root帐号远程连接数据库。如下:

 

init-mysql.sh

#!/bin/bash service mysql stop mkdir -pv /adm/mysql/{data,log,pid,tmp} chown -R mysql.mysql /adm/mysql chmod -R 0755 /adm/mysql mysql_install_db --user=mysql --ldata=/adm/mysql/data /bin/cp ./my.cnf /etc/ chmod 0600 /etc/my.cnf cd /var/lib/mysql/ /bin/ls | sed '/mysql.sock/d' | xargs rm -rf cd - service mysql start /usr/bin/mysql_secure_installation <<EOF y bbnd_adm bbnd_adm y y y y EOF service mysql restart

 

一个my.cnf文件,用于设定MySQL的配置, 如下:

my.cnf

[client] #password = [your_password] port = 3306 socket = /var/lib/mysql/mysql.sock host =localhost password vertical #pager =less [mysqld] big-tables #bind-address = 192.168.1.20 back_log = 50 core-file #default-storage-engine = INNODB datadir = /adm/mysql/data/ innodb=FORCE innodb_data_home_dir = /adm/mysql/data innodb_data_file_path =ibdata1:512M:autoextend innodb_log_group_home_dir = /adm/mysql/log/ #innodb_log_arch_dir = /adm/mysql/log/ innodb_autoextend_increment =512 innodb_buffer_pool_size =128M concurrent_insert delayed_insert_timeout = 300 delayed_queue_size = 1024 interactive_timeout = 3600 #log = log-error = /adm/mysql/log/mysql general_log = ON log-output = FILE expire_logs_days = 15 #user security safe-user-create secure-auth skip-show-database open_files_limit = 1024 #skip-network connect_timeout = 30 max_connect_errors = 10 max_user_connections = 512 max_connections = 512 max_delayed_threads = 64 max_error_count = 1024 port = 3306 socket = /var/lib/mysql/mysql.sock

 

 

你可能感兴趣的:(mysql,数据库,socket,buffer,insert,远程连接)