switch slowlog file

#!/bin/bash

# define common variables

log_home="/data/mysql/logs"

host_prefix=`uname -n | awk -F . '{print $1}'`

current_time=`date "+%Y%m%d"`

current_log_file="${host_prefix}.mysqlslow_${current_time}.log"

switch_log="/tmp/switchlog"

mysql_user=root

mysql_pass=root

touch ${log_home}/${current_log_file}

chown mysql.mysql ${log_home}/${current_log_file}

mysql  -u${mysql_user} -p${mysql_pass} -e "set global slow_query_log=0">>${switch_log}

mysql  -u${mysql_user} -p${mysql_pass} -e "set global slow_query_log_file='${log_home}/${current_log_file}'; ">>${switch_log}

mysql  -u${mysql_user} -p${mysql_pass} -e "set global slow_query_log=1">>${switch_log}

你可能感兴趣的:(mysql,java,数据库)