Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Multi-instance MySQL startup script

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Develop mysql multi-instance startup scripts:

The known mysql multi-instance startup command is: mysqld_safe-defaults-file=/data/3306/my.cnf &

The stop command is: mysqladmin-u root-p123456-S / data/3306/mysql.sock shutdown

Requirements: implemented with functions, case statements, if statements, etc.

#! / bin/sh [- f / etc/init.d/functions] & &. / etc/init.d/functions | | exit#Define VariablesPort=$1Mysql_user=rootMysql_sock=/data/$ {Port} / mysql.sockPath=/application/mysql/binRETVAL=0#Define Start Functionstart () {if [!-e "$Mysql_sock"]; then / bin/sh $Path/mysqld_safe-- defaults-file=/data/$ {Port} / my.cnf 2 > & 1 > / dev/null & RETVAL=$? If [$RETVAL-eq 0]; then action "Starting $Port MySQL..." / bin/true else action "Starting $Port MySQL..." / bin/false fi else echo "$Port MySQL is Running..." Fi return $RETVAL} # Define Stop Functionstop () {if [!-e "$Mysql_sock"]; then echo "$Port MySQL is Stopped..." Else read-p "Please Input $Port MySQL Password:" PWD Mysql_pwd=$PWD $Path/mysqladmin-u ${Mysql_user}-p$ {Mysql_pwd}-S / data/$ {Port} / mysql.sock shutdown RETVAL=$? If [$RETVAL-eq 0]; then action "Stopping $Port MySQL..." / bin/true else action "Stopping $Port MySQL..." / bin/false fi fi return $RETVAL} case "$2" in start) start RETVAL=$?;; stop) stop RETVAL=$?;; restart) stop sleep 3 start RETVAL=$? *) echo-e "USAGE:$0 {3306 | 3307 | 3308} {start | stop | restart}" RETVAL=2;; esacexit $RETVAL

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report