#!/bin/Bashdatadir="/mydata/data"sqlconf=/etc/Mysqlinstalldir=/usr/local/mysql# about the installation package you can go to the official website to download, pay attention to download the common binary format, and then put on the FTP server can be # here assume I put mariadb5.5 's installation package on the FTP/pub/sources/6. x86_64/MARIADB below Case$1 inch $) Package=mariadb-5.5. $-linux-x86_64.Tar. GZdir=mariadb-5.5. $-linux-x86_64wgetLftp172.16.0.1:/pub/sources/6. x86_64/mariadb/$package;; +) Package=mariadb-5.5. +-linux-x86_64.Tar. GZdir=mariadb-5.5. +-linux-x86_64wgetLftp172.16.0.1:/pub/sources/6. x86_64/mariadb/$package;;*) Echo "Usage/bin/bash ' basename $ ' 36|40"Exit1Esac#Echo 'Get mariadb-5.5.36-linux-x86_64.tar.gz#bye'| lftp 172.16.0.1:/pub/sources/6.x86_64/mariadbTarXF ${package}-c/usr/LOCALCD/usr/local# for it to create links MySQL easy to manage laterLN-S ${dir} MYSQLCD ${installdir} #创建mysql系统用户if!IDMySQL &>/dev/NULL; ThenUseradd-R MySQLfi# Create a data file directoryif[!-d ${datadir}]; Then mkdir-PV ${datadir} &>/dev/NULL Chown-R mysql:mysql ${datadir}fi# Initialize MARIADBCD ${installdir}scripts/mysql_install_db--user=mysql--datadir=/mydata/data &>/dev/NULL# Add a configuration file for mariadbif[!-d ${sqlconf}]; Then mkdir-p/etc/mysql &>/dev/NULLfiCD ${installdir}CPsupport-files/my-large.cnf/etc/mysql/my.cnfsed-I.'/^thread_ca/a \datadir =/mydata/data \ninnodb_file_per_table = on \nskip_name_resolve = on'/etc/mysql/my.cnf# Adding service scripts for mariadbCP${installdir}/support-files/mysql.server/etc/rc.d/init.d/Mysqldchkconfig--add mysqld# Adding mariadb command to PATH environment variableEcho 'export Path=/usr/local/mysql/bin: $PATH'>/etc/profile.d/mysql.SH. /etc/profile.d/mysql.SH# Add man manualsed-I.'/^man.*\/usr\/man/a manpath/usr/local/mysql/man/'/etc/Mans. configEcho 'The mariadb has installed successfully'Echo 'Please Exect ". /etc/profile.d/mysql.sh "To update PATH'
Automated installation of shell scripts Universal binary format mariadb