当前位置:Gxlcms > 数据库问题 > mysql启动服务配置文件编写

mysql启动服务配置文件编写

时间:2021-07-01 10:21:17 帮助过:14人阅读


#   and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable


basedir=/usr/local/mysql/bin #mysql按装位置
datadir=/home/mysql_db     #mysql数据存放位置
defaults=/etc/my.cnf           #启动指定的配置文件


# Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
# Value here is overriden by value in my.cnf.
# 0 means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=900


# Lock directory for RedHat / SuSE.
lockdir='/var/lock/subsys'
lock_file_path="$lockdir/mysql"


#./etc/init.d/functions
function_usage() {
   echo "$0 {start|stop|restart|status}"
   exit 1
}
[ $# -ne 1 ] && $(function_usage)
function_mysql_start(){
 $basedir/mysqld --defaults-file=$defaults & > /dev/null
 if [ $? -eq 0 ]; then
     sleep 2
     echo -e  "\033[32m mysqld start success.....\033[0m"
 else
     sleep 2
     echo  -e "\033[31m mysqld start failed......\033[0m"
     echo -e "\033[31m please mysql is exists \033[0m"
 fi
}
function_mysql_stop() {
    $basedir/mysqladmin -uroot -p1qaz2wsx shutdown & > /dev/null
    if [ $? -eq 0 ]; then
      echo  -e "\033[32m mysqld stop success......\033[0m"
    else
       echo  -e "\033[31m mysqld stop failed......\033[0m"
       echo -e "\033[31m please mysql is exists \033[0m"
    fi
}
funtion_mysql_restart(){
   function_mysql_stop
   sleep 2
   function_mysql_start
}
case $1 in
   start)
      function_mysql_start
   ;;
   stop)
      function_mysql_stop
   ;;
   restart)
     funtion_mysql_restart
    ;;
   status)
       ps -ef |grep mysql|grep -v grep
   ;;
   *)
    printf "Usage:$0 {start|stop|restart|status}\n"
esac

mysql启动服务配置文件编写

标签:int   his   inux   server   err   should   basedir   ldap   weight   

人气教程排行