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

Develop mysql single-instance or multi-instance startup scripts

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

Share

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

Single instance

Launch: mysqld_safe-- user=mysql &

Stop: mysqladmin-u root-proot shutdown

Development script

#! / bin/bash#chkconfig: 2345 30 50#Date:2017-6-29#Author:xcn (baishuchao@yeah.net) # version UltimatesPID= "/ var/run/mysqld/mysqld.pid" user= "root" # defines the username password pass= "root" path= "/ usr/bin". / etc/init.d/functionsfunction usage () {echo "$0 {start | stop | restart}" exit 1} [$#-ne 1] & & usage # execute the usage function # start_mysqlfunction start_mysql () {if [!-f $PID] then $path/mysqld_safe-- user=mysql & > / dev/null 2 > & 1 # when the sign $# equals 1 If [$?-eq 0] then action "start mysql" / bin/true else action "start mysql erro" / bin/false fielse echo "mysqld is running" fi} # stop_mysqlfunction stop_mysql () {$path/mysqladmin-u $user-p$pass shutdown > / dev/null 2 > & 1 if [$?-eq 0] then Action "stop mysql" / bin/true else action "stop mysql erro" / bin/false fi} # pass parameters to determine the execution of if ["$1" = = "start"] then start_mysqlelif ["$1" = = "stop"] then stop_mysqlelif ["$1" = = "restart"] then stop_mysql start_mysqlelse # if you do not conform to the above, print the usage function usagefi

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

Wechat

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

12
Report