博客
关于我
MySQL单实例或多实例启动脚本
阅读量:789 次
发布时间:2023-02-12

本文共 860 字,大约阅读时间需要 2 分钟。

以下是优化后的文章内容:


MySQL数据库自动启动和停止脚本

脚本简介

#!/bin/bash

脚本依赖

. /etc/init.d/functions

脚本参数

user=rootpass=888888path=/application/mysql/bin

功能说明

function usage(){    echo "Usage:$0 {start|stop|restart|}"    exit 1}

脚本逻辑

function start_db(){    $path/mysqld_safe --user=$user > /dev/null &    if [ $? -eq 0 ]; then        echo "starting MySQL..." true    else        echo "starting MySQL..." false    fi}function stop_db(){    $path/mysqladmin -u$user -p$pass shutdown > /dev/null    if [ $? -eq 0 ]; then        echo "stoping MySQL..." true    else        echo "stop MySQL..." false    fi}

脚本执行规则

if [ "$1" == "start" ]; then    start_dbelif [ "$1" == "stop" ]; then    stop_dbelif [ "$1" == "restart" ]; then    stop_db    sleep 3    start_dbelse    usagefi

使用说明

# 启动 MySQL./mysqld01.sh start# 停止 MySQL./mysqld01.sh stop# 重启 MySQL./mysqld01.sh restart

本文内容来源于:51CTO技术博客

转载地址:http://pmbfk.baihongyu.com/

你可能感兴趣的文章
mysql case when 乱码_Mysql CASE WHEN 用法
查看>>
Multicast1
查看>>
MySQL Cluster 7.0.36 发布
查看>>
Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译
查看>>
multipart/form-data与application/octet-stream的区别、application/x-www-form-urlencoded
查看>>
mysql cmake 报错,MySQL云服务器应用及cmake报错解决办法
查看>>
Multiple websites on single instance of IIS
查看>>
mysql CONCAT()函数拼接有NULL
查看>>
multiprocessing.Manager 嵌套共享对象不适用于队列
查看>>
multiprocessing.pool.map 和带有两个参数的函数
查看>>
MYSQL CONCAT函数
查看>>
MySQL Connector/Net 句柄泄露
查看>>
multiprocessor(中)
查看>>
mysql CPU使用率过高的一次处理经历
查看>>
Multisim中555定时器使用技巧
查看>>
MySQL CRUD 数据表基础操作实战
查看>>
multivariate_normal TypeError: ufunc ‘add‘ output (typecode ‘O‘) could not be coerced to provided……
查看>>
multi_index_container
查看>>
mutiplemap 总结
查看>>
MySQL Error Handling in Stored Procedures---转载
查看>>