MySQL installation script

Source: Internet
Author: User

Mysql

#/bin/Bash #--------Variable #num= 'Expr $RANDOM%3 m1' Now_lujing= 'Pwd`#-------------------------Configure user File functionsfunctionUser_file_config () {#-----------------------------------Add group, user groupadd MySQL &>/dev/NullUseradd mysql-g mysql-s/sbin/Nologin #-----------------------------------Set up the installation directory for the necessary files #mysqlMkdir-p/usr/local/MySQL #Mysql数据目录Mkdir-p/data/MySQLdb #创建BINLOG日志目录Mkdir-p/data/mysqldb/Binlog #创建MYSQL daily Log directoryMkdir-p/data/mysqldb/Log #数据库临时目录mkdir/opt/Mysqltmp #解压编译mysql源码 Make_mysql; #给Mysql安装目录进行授权Chown Mysql:mysql/usr/local/mysql-r#---------------------------------Change permissionsChown mysql:mysql/opt/mysqltmp#-Authorizing the MySQL data storage directoryChown Mysql:mysql/data/mysqldb-r#-Authorizing the MYSL log directoryChown mysql:mysql/data/mysqldb/binlog/Chown mysql:mysql/data/mysqldb/log/#开始初始化 # Copy configuration fileEcho y|CP $now _lujing/my.cnf/etc/my.cnf# Specify the user, user, run directory/usr/local/mysql make data storage file/data/mysqldb/usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysqldb# Copy the command into the Init.d file.cp/usr/local/mysql/support-files/mysql.server/etc/init.d/Mysqldchmod755/etc/init.d/mysqld# start the service and set the environment variable #:vim/etc/The last side of the profile# file.Echo-e"Mysql=/usr/local/mysql/bin \npath=\ $PATH: \ $MYSQL \nexport PATH">>/etc/profile# effective source/etc/Profile}functionMake_mysql () {if [!-D mysql-5.6.31]ThenTAR-XVF mysql-5.6.31.Tar. gzFiCD mysql-5.6.31cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_unix_addr=/tmp/mysql.sock-dsysconfdir=/etc-ddefault_charset=gbk-ddefault_collation=Gbk_chinese_ci-dwith_innobase_storage_engine=1-dwith_archive_storage_engine=1-dwith_blackhole_storage_engine=1-dwith_federated_storage_engine=1-dwith_partition_storage_engine=1-dmysql_datadir=/data/mysqldb-dmysql_tcp_port=3306Make &&MakeInstall}#-------Check if the Yum source is configured successfullyfunctionCheck_yum () {Yum Clean all &>/dev/NullYum repolist &>/tmp/Repolist.los rpm_num= 'cat/tmp/repolist.los|grep repolist|Awk‘{Print $}‘`#Echo$rpm _numif ["$rpm _num" =="0"]Thenecho Error: 'Date +%f-%r ' Yum source is not configured well >>Mysql_logElseecho Error: 'Date +%f-%r ' yum source configured >>Mysql_logYumInstallgcc gcc-c++ ncurses-devel perl camke Bison cmake-y [$?-eq 0] && echo-e succed:"
                                                                                                                                         
                                                                                                                                           ' Date +%f-%r ' \tmysql required dependency package has been successfully installed >>mysql_log
                                                                                                                                          "| | Echo-e Filed:"' date +%f-%r ' \tmysql required dependency package not installed successfully >>mysql_log" fi}function Main () {Check_yum; user_file_config# start service/etc/init.d/mysqld start}main;      
                                                                                                                                         

My.cnf

[Client]port=3306Socket=/tmp/Mysql.sock[mysqld] #baseport=3306User=Mysqlsocket=/tmp/Mysql.sockpid-file=/tmp/Mysql.pidbasedir=/usr/local/Mysqldatadir=/data/Mysqldbtmpdir=/opt/Mysqltmpopen_files_limit=10240Explicit_defaults_for_timestampsql_mode=no_engine_substitution,strict_trans_tablesfederated server_id=706#replicate- Do-db =posp#replicate-ignore-db =Mysql#log-slave-updates =1Event_scheduler=1max_connections= -max_connect_errors=10000Interactive_timeout= -Wait_timeout= -Skip-name-Resolvesync_binlog=0log_bin_trust_function_creators=1character-set-server =Utf8default_storage_engine=Innodb#loglog-bin =/data/mysqldb/binlog/mysql-binbinlog_cache_size=32mmax_binlog_cache_size=10gbinlog_stmt_cache_size=32mtable_open_cache=2048max_binlog_size=1024mbinlog_format=Mixedlog_output=FileLog-error =/data/mysqldb/log/mysql-Error.logslow_query_log=1Slow_query_log_file=/data/mysqldb/log/mysql-Slow_query.loggeneral_log=0General_log_file=/data/mysqldb/log/mysql-general-Query.logexpire-logs-days = -Relay-log =/data/mysqldb/binlog/relay-Binrelay-log-index=/data/mysqldb/binlog/relay-bin.index#buffersort_buffer_size=2m read_buffer_size=2mread_rnd_buffer_size=2mjoin_buffer_size=2mnet_buffer_length=16kmax_allowed_packet=512mbulk_insert_buffer_size=32mmax_heap_table_size=512mtmp_table_size=512mthread_cache_size= -query_cache_size=256mquery_cache_limit=10mquery_cache_min_res_unit=4kkey_buffer_size=16mmyisam_sort_buffer_size=64mmyisam_max_sort_file_size=10gmyisam_repair_threads=1#innodbinnodb_file_per_table=1Innodb_data_file_path=ibdata1:2048m:autoextendinnodb_log_file_size=128minnodb_log_files_in_group=3innodb_buffer_pool_size=1ginnodb_buffer_pool_instances= -1innodb_max_dirty_pages_pct= -#innodb_thread_concurrency=8Innodb_flush_method=o_directinnodb_log_buffer_size=16minnodb_flush_log_at_trx_commit=2[Mysql]no-auto-rehashprompt=(\[email protected]\h) [\d]\_default-character-set = UTF8

MySQL installation script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.