Mysql多執行個體之mysql服務指令碼

來源:互聯網
上載者:User

標籤:oca   detail   local   err   ica   tail   .so   printf   /dev/null   

 

1.

#initport=3306mysql_user="root"mysql_pwd="cancer"CmdPath="/application/mysql/bin"mysql_sock="/data/${port}/mysql.sock"#startup functionfunction_start_mysql(){ if [ ! -e "$mysql_sock" ];then  printf "Starting MySQL...\n"  /bin/sh ${CmdPath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2>&1 > /dev/null & else  printf "MySQL is running...\n" exit fi}#stop functionfunction_stop_mysql(){      if [ ! -e "$mysql_sock" ];then        printf "MySQL is stopped...\n"        exit      else        printf "Stoping MySQL...\n"        ${CmdPath}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S /data/${port}/mysql.sock shutdown      fi}#restart functionfunction_restart_mysql(){  printf "Restarting MySQL...\n"  function_stop_mysql  sleep 2  function_start_mysql}case $1 in start) function_start_mysql;;stop) function_stop_mysql;;restart) function_restart_mysql;;*)  printf "Usage: /data/${port}/mysql {start|stop|restart}\n"esac

http://blog.csdn.net/u011364306/article/details/47814409

2.

#!/bin/bashmysql_port=3307mysql_username="admin"mysql_password="password"function_start_mysql(){printf "Starting MySQL...\n"/bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/dbdata_${mysql_port}/my.cnf 2>&1 > /dev/null &}function_stop_mysql(){printf "Stoping MySQL...\n"/usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /data/dbdata_${mysql_port}/mysql.sock shutdown}function_restart_mysql(){printf "Restarting MySQL...\n"function_stop_mysqlfunction_start_mysql}function_kill_mysql(){kill -9 $(ps -ef | grep ‘bin/mysqld_safe‘ | grep ${mysql_port} | awk ‘{printf $2}‘)kill -9 $(ps -ef | grep ‘libexec/mysqld‘ | grep ${mysql_port} | awk ‘{printf $2}‘)}case $1 instart)function_start_mysql;;stop)function_stop_mysql;;kill)function_kill_mysql;;restart)function_stop_mysqlfunction_start_mysql;;*)echo "Usage: /data/dbdata_${mysql_port}/mysqld {start|stop|restart|kill}";;esac

  

http://blog.csdn.net/zhoufoxcn/article/details/73065655?utm_source=tuicool&utm_medium=referral

Mysql多執行個體之mysql服務指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.