9,、提供简易管理脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#!/bin/bash # basedir=/usr/local/mysql bindir=/usr/local/mysql/bin conf=/data/multi.cnf export PATH=$bindir:/$PATH if test -x $bindir/mysqld_multi then mysqld_multi="$bindir/mysqld_multi"; else echo "Can't execute $bindir/mysqld_multi from dir $basedir"; exit; fi case "$1" in 'start' ) "$mysqld_multi" --defaults-extra-file=$conf start $2 ;; 'stop' ) "$mysqld_multi" --defaults-extra-file=$conf stop $2 ;; 'report' ) "$mysqld_multi" --defaults-extra-file=$conf report $2 ;; 'restart' ) "$mysqld_multi" --defaults-extra-file=$conf stop $2 "$mysqld_multi" --defaults-extra-file=$conf start $2 ;; *) echo "Usage: $0 {start|stop|report|restart}" >&2 ;; esac |
10、为mysql的root用户创建密码
1 |
mysqladmin -uroot -S /tmp/mysql.sock2 password "123456" #指定socket文件位置即可 |
其余的操作一样
11、附,多配置文件安装mysql多实例,这里增加mysql 的3309端口
1 2 3 4 5 |
mkdir -pv /data/3309/data chown mysql.mysql -R 3309/ cd /usr/local/mysql scripts/mysql_install_db --datadir=/data/3309/data/ --user=mysql --basedir=/usr/local/mysql/ cp support-files/my-small.cnf /data/3309/my.cnf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
vim /data/3309/my.cnf [client] port = 3309 #这里也需要注意下吧 socket = /tmp/mysql.sock4
[mysqld] port = 3309 #注意端口 socket = /tmp/mysql.sock4 #注意socket skip-external-locking key_buffer_size = 16K max_allowed_packet = 1M table_open_cache = 4 sort_buffer_size = 64K read_buffer_size = 256K read_rnd_buffer_size = 256K net_buffer_length = 2K thread_stack = 128K datadir=/data/3309/data #注意datadir server-id = 1
[mysqldump] quick max_allowed_packet = 16M |
1 |
mysqld_safe --defaults-file=/data/3309/my.cnf 2&1> > /dev/null #启动mysqld |
1 2 3 4 5 |
ss -tnl | grep 330 #查看端口 LISTEN 0 50 *:3306 *:* LISTEN 0 50 *:3307 *:* LISTEN 0 50 *:3308 *:* LISTEN 0 50 *:3309 *:* |
其余启动方法与关闭方法类似
12、总结:
1).通过这次mysql多实例安装,我们已经可以根据自己的喜好决定是通过多配置文件安装mysql多实例,还是但配置单文件安装。
2).过程比较简单,也没有什么特别高明的技巧,但是由小见大,以后配置文件可以在完善完善。
3).就是下面还会用心的写一系列的mysql博客,希望高手指点,不胜感激
参考链接:http://freeloda.blog.51cto.com/2033581/134931