日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

shell脚本安装mysql并安装一个小服务

發布時間:2025/3/21 数据库 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 shell脚本安装mysql并安装一个小服务 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?!!!!!!改配置文件盡量手寫,手寫,手寫

#!/bin/bash #更改主機名 hostnamectl set-hostname mysql a=`ss -nulpt | grep 3306 | awk -F: '/tcp/{print $4}'` if [ ${a} == 3306 ];thenecho "install mysql"echo "ok" elseecho "no install mysql" #創件yum倉庫echo -e "[mysql57-community]\nname=MySQL 5.7 Community Server\nbaseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/local.repoyum clean all && yum makecache &> /dev/null #裝包 yum install -y php php-xml php-json mysql-community* &> /dev/nullsystemctl enable mysqld --nowb=`ss -nulpt | grep 3306 | awk -F: '/tcp/{print $4}'`if [ ${b} == 3306 ];thenecho "install mysql"if [ $? == 0 ];thenecho "ok"mysqladmin -uroot -p`grep -i password /var/log/mysqld.log | awk 'NR==1{print $11}'` password NSD2021@tedu.cnecho "passwd is ok"elseecho "no"fifi fi #!/bin/bash #安裝mysql mysql () { #更改主機名 hostnamectl set-hostname mysql ss -nulpt | grep 3306 if [ $? == 0 ];thenecho "install mysql"echo "ok" elseecho "no install mysql" #創件yum倉庫echo -e "[mysql57-community]\nname=MySQL 5.7 Community Server\nbaseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/local.repoyum clean all && yum makecache &> /dev/nullyum install -y php php-xml php-json mysql-community* &> /dev/nullsystemctl enable mysqld --nowb=`ss -nulpt | grep 3306 | awk -F: '/tcp/{print $4}'`if [ ${b} == 3306 ];thenecho "install mysql"if [ $? == 0 ];thenecho "ok"mysqladmin -uroot -p`grep -i password /var/log/mysqld.log | awk 'NR==1{print $11}'` password NSD2021@tedu.cnecho "passwd is ok"elseecho "no"fifi fi unset a b }#下載nginx nginx () { ls nginx-1.5.7.tar.gz >> /dev/null if [ $? == 0 ];thenecho "install ok" elseecho "no install"yum -y install wget tar >> /dev/nullwget http://nginx.org/download/nginx-1.5.7.tar.gzls nginx-1.5.7.tar.gzif [ $? == 0 ];thenecho "ok"elseecho "on"fi fi }#安裝nginx nginx_install () { ls /usr/local/nginx >> /dev/null if [ $? == 0 ];thenecho "install ok" elseecho "no install"for i in php-fpm php-mysql gcc pcre-devel zlib-develdoyum install -y $idonetar xf nginx-1.5.7.tar.gzcd nginx-1.5.7 && ./configuremake && make installsystemctl enable php-fpm --now fi }#更改配置文件支持動態服務 wen () { cp nginx.conf /usr/local/nginx/conf/nginx.conf /usr/local/nginx/sbin/nginx -t if [ $? == 0 ];thenecho "ok" elseecho "no" fi }#服務設置 service () { read -p "請輸入你要起的服務[nginx,php-fpm]:" q case $q in php)read -p "請輸入start,restart,stop:" icase $i instart)systemctl start php-fpm;;restart)systemctl restart php-fpm;;stop)systemctl stop php-fpm;;*)echo "輸入錯誤請重新輸入start,restart,stop"esacecho "設置成功";; firewalld)read -p "請輸入start,restart,stop:" icase $i instart)systemctl start firewalld;;restart)systemctl restart firewalld;;stop)systemctl stop firewalld;;trusted)firewall-cmd --set-default-zone=trusted;;*)echo "輸入錯誤請重新輸入start,restart,stop"esacecho "設置成功";; nginx)read -p "請輸入start,restart,stop:" icase $i instart)/usr/local/nginx/sbin/nginx;;restart)/usr/local/nginx/sbin/nginx -s reload;;stop)/usr/local/nginx/sbin/nginx -s stop;;*)echo "輸入錯誤請重新輸入start,restart,stop"esacecho "設置成功";; selinux)setenforce 0sed -i '/SELINUX/s/enforcing/permissive/' /etc/selinux/config;; *)echo "請重新輸入你要起的服務[nginx,php-fpm,firewalld,selinux]";; esac }#上線服務 html () { read -p "請輸入mysql_bbs,wordpress:" i case $i in wordpress)cdunzip wordpress.zipcd wordprestar -xf wordpress-5.0.3-zh_CN.tar.gzcp -r wordpress/* /usr/local/nginx/html/chown -R apache.apache /usr/local/nginx/html/;; mysql_bbs)cp -r /root/php_mysql_bbs/* /usr/local/nginx/html/;; *)echo "請重新輸入你要起的服務[mysql_bbs,wordpress]";; esac }

總結

以上是生活随笔為你收集整理的shell脚本安装mysql并安装一个小服务的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。