mysql多实例的安装和管理(一台服务器上运行两个mysql实例)
在服务器上搭建多mysql实例
#vim /etc/init.d/mysql_3400
#!/bin/bash mysql_port=3400 #server_num=total mysql_username="root" mysql_password="password" function_start_mysql() { printf "Starting MySQL...\n" /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my_conf/ios/ios_total.cnf 2>&1 > /dev/null & } function_stop_mysql() { printf "Stoping MySQL...\n" /usr/local/mysql/bin/mysqladmin -S /home/work/mysql/ios/ios_total/mysql.sock shutdown } function_restart_mysql() { printf "Restarting MySQL...\n" function_stop_mysql function_start_mysql } function_kill_mysql() { kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}') kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}') } case $1 in start) function_start_mysql;; stop) function_stop_mysql;; kill) function_kill_mysql;; restart) function_stop_mysql function_start_mysql;; *) echo "Usage: /home/work/mysql/ios/ios_total/mysqld {start|stop|restart|kill}";; esac