Shell scripting topics-----------fully automated compilation and installation of MySQL

Source: Internet
Author: User

MySQL compilation installation, in the blog Open Source Service topic--------MySQL compiled installation has been explained, but still more trouble, especially a lot of commands, to manually execute, slightly careless, will be wrong. Production is generally first in the local test environment for automated testing, if OK, then on the production of automated installation, easy, labor-saving, safe.

This article environment:

centos6.5x64, MySQL version: mysql-5.6.26. Install with automated compilation.

Related preparatory work:

Familiar with sed text compilation commands, expect the use of interactive scripts.

In advance to put the installation of the MySQL installation package under/root, of course, the download process can also be written in the script, in order to save time, the download process is generally not written in the script, and a lot of production environment is not able to connect the external network.

[[email protected] ~]# ls
Anaconda-ks.cfg install.log install.log.syslog mysql-5.6.26.tar.gz mysql_install_auto.sh

Here's my script: mysql_install_auto.sh's content:

[email protected] ~]# cat mysql_install_auto.sh

#!/bin/bashmysql_passwd= "123456" yum remove-y mysql mysql-serveryum install-y cmake ncurses-devel Tar XF mysql-5.6.2 6.tar.gz-c/usr/local/src/cd/usr/local/src/mysql-5.6.26useradd-m-s/sbin/nologin MySQL Cmake-dcmake_install_prefix =/usr/local/mysql-dmysql_unix_addr=/tmp/mysql.sock-ddefault_charset=utf8-ddefault_collation=utf8_general_ci- Dwith_extra_charsets=all-dwith_myisam_storage_engine=1-dwith_innobase_storage_engine=1-dwith_memory_storage_ Engine=1-dwith_readline=1-denabled_local_infile=1-dmysql_datadir=/usr/local/mysql/data-dmysql-user=mysqlmake-j 4 && make INSTALLCD && chown-r mysql:mysql/usr/local/mysql/cp/usr/local/mysql/support-files/ MY-DEFAULT.CNF/ETC/MY.CNF cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqldsed-i ' s%^basedir=% basedir=/usr/local/mysql% '/etc/init.d/mysqldsed-i ' s%^datadir=%datadir=/usr/local/mysql/data% '/etc/init.d/ Mysqldchkconfig mysqld on/usr/local/mysql/scripts/mysql_install_db--defaultS-FILE=/ETC/MY.CNF--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/--user=mysqlls/usr/local/mysql/ Data/ln-s/usr/local/mysql/bin/*/bin/service mysqld Startecho "Now let's begin Mysql_secure_installation" if [! -e/usr/bin/expect] then yum install expect-y fiecho ' #!/usr/bin/expectset timeout 60set password [lindex $argv 0]spaw  n Mysql_secure_installationexpect {"Enter for none" {send "\ r"; exp_continue} "y/n" {send "y\r"; exp_continue} "Password" {send "$password \ r"; Exp_continue} "cleaning up" {send "\ r"}}interact ' > Mysql_secure_installation.exp chmod +x mysq  L_secure_installation.exp./mysql_secure_installation.exp $MYSQL _passwd

[[Email protected] ~]# sh mysql_install_auto.sh//execute the script directly.

The script is a shell script, and finally, when the MySQL database is safely initialized, a expect script is generated: Mysql_secure_installation.exp.

Description: To enhance the script's neat appearance and readability, removed a lot of if judgment and echo $? Determine if the script is successful.

MySQL Compile the instructions in the installation of related commands and parameters in my blog: Open Source Service topics--------MySQL compilation and installation already has the detailed explanation, therefore this article does not repeat.

This script has been tested completely correctly.

This article is the author's original blog, reproduced please indicate the source: http://www.cnblogs.com/jasmine-Jobs/p/6045469.html

Shell scripting topics-----------fully automated compilation and installation of MySQL

Related Article

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.