#!/bin/bash# # rrogram:#Installmysql# history:# .-Ten- toLuoqi V0.1release# email:#916790942@qq. com #以下rpm包需要自己下载并和该脚本放在同一目录下 #mysql-community-server-5.7. +-1. el7.x86_64.rpm mysql-community-client-5.7. +-1. el7.x86_64.rpm mysql-community-common-5.7. +-1. el7.x86_64.rpm #mysql-community-libs-5.7. +-1. el7.x86_64.rpm## dependenceYum-YInstall PerlYum-YInstall-YPerl-module-Install.noarchYum-YInstallnet-tools#created by Kevin ./Geneva/ -, modify ./Geneva/ -# -----------------------------------------------------------------------------# installation Script forThe auto-Deployment EMM (Linux edition) #-----------------------------------------------------------------------------# -----------------------------------------------------------------------------# shell Script toInstallMySQL (Default version mysql-community-5.7. +)Echo "-----------------------start install MySQL----------------------"# ADD to MySQL user and MySQL groupif[ `grep "MySQL"/etc/passwd|WC-L '-eq0]; ThenEcho "adding user MySQL"Groupadd Mysqluseradd-R-g MySQL MySQLElseEcho "MySQL user is exist"fi# Check installed MySQL or not forIinch' Rpm-qa |grep "MySQL"` Dorpm-e--allmatches $i--nodeps Done# Remove Pre-installed on OS MariaDBifexists forIinch$ (Rpm-qa |grepmariadb |grep-Vgrep) Do Echo "Deleting rpm --"$i rpm-E--nodeps $i Done# Install mysqlserverrpm-IVH mysql-community-server-5.7. +-1. el7.x86_64.rpm mysql-community-client-5.7. +-1. el7.x86_64.rpm mysql-community-common-5.7. +-1. el7.x86_64.rpm mysql-community-libs-5.7. +-1. el7.x86_64.rpm# Check the installtation is successful or not RPM-qa |grep "MySQL"if[ $? !=0]; ThenEcho "MySQL Install fail"|Tee$mysql _instlogexit1Else Echo "MySQL Isntall success"|Tee$mysql _instlogfi# Modify configuration Files CD/etc/Echo "Character_set_server=utf8">>my.cnf# Startup The Mysqlsystemctl start mysqld systemctl status Mysqld/etc/init.d/mysqld Start/etc/init.d/mysqld StopEcho "MySQL Server Install successfully!"# ConfigurationCat/etc/my.cnfsed-I.'/mysqld/a\skip-grant-tables'/etc/my.cnfsystemctl restart mysqld# mysql-u root mysqlmysql-U root mysql-e"Use MySQL;"# Use mysql# update mysql.user set authentication_string=password ('Root') Where user='Root'; MySQL-U root mysql-e"Update Mysql.user Set Authentication_string=password (' root ') where user= ' root ';"MySQL-U root mysql-e"flush Privileges;"Cat/etc/my.cnfsed-I.'/skip-grant-tables/s/^/#/'/etc/my.cnf# MySQL-U Root-p# SET PASSWORD= PASSWORD ('Root'); MySQL-U root-proot--connect-expired-password-e"SET PASSWORD = PASSWORD (' root ');"Echo "Install successfully!!"# Exit
https://dev.mysql.com/downloads/mysql/download MySQL
Install MySQL with one click