Get the App
SLTechnology News&Howtos  ›  Database  › 

Develop mysql single-instance or multi-instance startup scripts

Shulou Source: shulou.com Published: 2022-06-01 03:53:25 11月16日 Update

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

Tags: Functions instances scripts developers passwords users usernames paths Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Microsoft Huawei Docker Linux