In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Mysql5.5, 5.6 automation installation script how to write, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Environment: ① CentOS6 & Cent OS7
Download mysql software package under ② networking environment
Script:
#! / bin/bash#Date 2018-9-10 [$(id-u)! = "0"] & & echo "Error: You must be root to run this script" & & exit 1#id-u detects that the current user id 0 is the root user export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binwhich mysqldif [$?-eq 0]; then#$? Exit status of the previous command, with 1 yum remove `yum list installed | grep mysql`-yexit 1fiif [!-d / opt] Then# [- d file] checks whether it is a directory Attached is 2mkdir / opt & & cd / optelsecd / optfiecho "# Atuo compilation and installation mysql5.5/5.6 #" echo "1 Install mysql-5.5" echo "2 Install mysql-5.6" echo "3 EXIT" read-p "Please input your choice:" NUMcase $NUM in1) echo-e "\ 033 [32m Start Install mysql-5.5 Now\ 033 [0m" wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.24.tar.gzTDIR=mysql-5.5.24; ; 2) echo-e "\ 033 [32m Start Install mysql-5.6 Now\ 033 [0m" wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gzTDIR=mysql-5.6.22;;3)echo "exit installer!" exit 1 political *) echo "Input Error! Pease input {1 | 2 | 3 | 4} "exit 0 places esacif [$?-eq 0]; thentar zxf $TDIR.tar.gzelseecho-e"\ 033 [32m Download error! Please check your network!!\ 033 [0m "exit 1fimysqlu = `awk-F:'$0cm exit mysqlUnip'/ etc/passwd | $0 means matching all domains: split, the first domain is $1; / part is the partition; mysql part is the mode Attached 3mysqlg = `awk-F:'$0 mysqlg mysqlg ne'/ etc/group | wc-l`if [$mysqlg-ne 0] & & [$MySQL-ne 0] Thenecho-e "\ 033 [32m mysql is exists!\ 033 [0m" else/usr/sbin/useradd-s / sbin/nologin mysqlfi [!-d / usr/local/mysql] & & mkdir-p / usr/local/mysqlyum install-y gcc gcc-c++ make cmake ncurses-devel bison libaio-develcd / opt/$TDIRcmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DMYSQL_UNIX_ADDR=/home/mysql/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=/home/mysql\-DMYSQL_USER=mysql\-DMYSQL_TCP_PORT=3306make & & make installif [$?-eq 0] Thenchown-R mysql.mysql / usr/local/mysqlecho "export PATH=$PATH:/usr/local/mysql/bin/" > > / etc/profilesource / etc/profilecp support-files/my-*.cnf / etc/my.cnfcp support-files/mysql.server / etc/init.d/mysqldchmod 755 / etc/init.d/mysqldchkconfig-add / etc/init.d/mysqldchkconfig mysqld-level 35 onfi/usr/local/mysql/scripts/mysql_install_db\-- user=mysql\-- ldata=/var/lib/mysql \-- basedir=/usr/local/mysql\-- datadir=/home/mysqlln-s / var/lib/mysql/mysql.sock / home/mysql/mysql.socksed-I # ^ basedir=.*$#basedir=/usr/local/mysql#' / etc/init.d/mysqld#-I means insert S for replacement; # sign for separator; attached 4sed-I's # ^ datadir=.*$#datadir=/home/mysql#' / etc/init.d/mysqld/etc/init.d/mysqld startStart= `echo $? `Netstat= `netstat-ntap | grep mysql | wc-l`if [$Start-eq 0] & & [$Netstat-eq 1]; thenecho-e "\ 033 [32m $TDIR is install success!\ 033 [0m" elseecho-e "\ 033 [32m $TDIR is install fail!\ 033 [0m" fi
Attachment 1: exit status value and its meaning
Meaning of state value
0 program runs successfully without problems
1-125 failed to run, script command, system command or parameter transfer error
126 the command was found but could not be executed
127 No command was found to run
> 128 command is forcibly terminated by the system
Annex 2: file operator
File operator file description-whether d file is a directory-whether e file exists-whether f file is a normal file, whether r file is readable, whether w file is writable, whether x file is executable, whether s file length is 0Mutel L file whether symbolic link
Annex III. Awk
Usage of awk call
① shell command: awk [- F domain delimiter] 'awk segment' input file
② awk program inserts script file awk-f awk script file input file
③ execute script. / awk script file input file
Annex IV. Sed
Usage of sed call
① shell command: sed [options] 'sed command' input file
② sed program inserts script file sed [options]-f sed script file input file
③ execute script. / sed script file input file
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.