Centos7 Mysql 一键安装(设置默认密码)、一键卸载脚本
生活随笔
收集整理的這篇文章主要介紹了
Centos7 Mysql 一键安装(设置默认密码)、一键卸载脚本
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
平臺:Centos7
安裝包:mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
兼容:Mysql8、5
一鍵安裝腳本:請在NEWPASS變量上寫下你要設置的默認密碼
#bin bash #mysql 8.0 @author Wang Jianbin @Data 20190601INSTALL_PACKAGE_PATH="./mysql/mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar"function init_environment(){rpm -e --nodeps mariadb-libsecho "uninstall about mariadb" }function change_password(){findpass=$(grep 'temporary password' /var/log/mysqld.log)initpass=${findpass##* }echo $initpassNEWPASS="Qasky1234"echo $NEWPASSSQL="ALTER USER 'root'@'localhost' IDENTIFIED BY \"${NEWPASS}\";flush privileges;"echo $SQLmysql --connect-expired-password --password="$initpass" -e "${SQL}"if [ $? -eq 0 ]thenecho "change password success"elseecho "change password fail"exitfi } function install(){init_environmentecho "Start the installation"tar -xvf $INSTALL_PACKAGE_PATHRPM_EXE=`ls |grep mysql-community-common*`rpm -ivh $RPM_EXERPM_EXE=`ls |grep mysql-community-libs-8*`rpm -ivh $RPM_EXERPM_EXE=`ls |grep mysql-community-client*`rpm -ivh $RPM_EXERPM_EXE=`ls |grep mysql-community-server*`rpm -ivh $RPM_EXEgroupadd mysqluseradd -g mysql mysqlmysqld --initialize --user=mysqlmysqld --initialize-insecure --user=mysqlsystemctl start mysqldchange_password }install一鍵卸載腳本:
function unstall(){rpm -e --nodeps mysql-community-server mysql-community-libs mysql-community-common mysql-community-clientrm -rf /var/log/mysqld.logrm -rf /var/lib/mysqlrm -rf /usr/share/mysql-8.0 }unstall?
總結
以上是生活随笔為你收集整理的Centos7 Mysql 一键安装(设置默认密码)、一键卸载脚本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tableau的骑行路线地理数据可视化
- 下一篇: Python3-网页爬取-批量爬取贴吧页