This article refers to:
Http://www.unixfbi.com/1.html
MySQL5.7 Installation Scripts
# cat mysql.sh groupadd mysqluseradd-g mysql -d/usr/local/mysql -s/sbin/nologin-m mysqlid mysqlyum instal L libaio-ymkdir/opt/mysql/-PV tar zxf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -c/opt/mysql/ln-s/opt/mysql/ MYSQL-5.7.18-LINUX-GLIBC2.5-X86_64/USR/LOCAL/MYSQLMKDIR/DATA/MYSQL/MYSQL3306/{DATA,LOGS,TMP}-pvchown-r Mysql.mysql/usr/local/mysqlchown-r MYSQL.MYSQL/DATACP my.cnf /etc/my.cnfcd/usr/local/mysql./bin/mysqld-- DEFAULTS-FILE=/ETC/MY.CNF --initializecp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld/etc/ Init.d/mysqld startecho "Export path= $PATH:/usr/local/mysql/bin" >>/etc/profilesource/etc/profilepasswd=$ ( grep ' password is '/data/mysql/mysql3306/data/error.log | awk ' {print $NF} ') mysql-uroot-p "$PASSWD"-- CONNECT-EXPIRED-PASSWORD-E "Alter user user () identified by ' llill2019 ';" Mysql-uroot-p ' llill2019 '-e "show databases;"
MySQL init script
function: Restore MySQL to initialization state after each MySQL function test [[email protected]_2_33]cat/data/mysql/initmysql.sh #!/bin/bashecho] *******delete The related folder of mysql******* "service mysqld restartservice mysqld Stoprm-rf/data/mysql/mysql3306/data/*rm-rf/dat A/mysql/mysql3306/logs/*chown-r mysql.mysql/usr/local/mysqlchown-r Mysql.mysql/dataecho "*******initialize the MySQL app******* "cd/usr/local/mysql./bin/mysqld--defaults-file=/etc/my.cnf --initializeecho" *******add the Auto-start Service for mysql******* "rm-rf/etc/init.d/mysqldcp/usr/local/mysql/support-files/mysql.server/etc/ Init.d/mysqldecho "*******start the MYSYQL Servcie and set password as ' llill2019 ' *******"/etc/init.d/mysqld startpasswd =$ (grep ' password is '/data/mysql/mysql3306/data/error.log | awk ' {print $NF} ') mysql-uroot-p "$PASSWD"-- CONNECT-EXPIRED-PASSWORD-E "Alter user user () identified by ' llill2019 ';" Mysql-uroot-p ' llill2019 '-e "show databases;"
1-3 MySQL5.7 installation scripts and initialization scripts