mysql多实例

mysql的多实例有两种方式可以实现,两种方式各有利弊。
第一种是使用多个配置文件启动不同的进程来实现多实例,这种方式的优势逻辑简单,配置简单,缺点是管理起来不太方便。
第二种是通过官方自带的mysqld_multi使用单独的配置文件来实现多实例,这种方式定制每个实例的配置不太方面,优点是管理起来很方便,集中管理。

下面就分别来实战这两种多实例的安装和管理

先来学习第一种使用多个配置文件启动多个不同进程的情况:

环境介绍:

mysql 版本:5.1.50

操作系统:SUSE 11

mysql实例数:3个

实例占用端口分别为:3306、3307、3308

创建mysql用户
 

点击(此处)折叠或打开

  1. /usr/sbin/groupadd mysql
  2. /usr/sbin/useradd -g mysql mysql
编译安装mysql

点击(此处)折叠或打开

  1. tar xzvf mysql-5.1.50.tar.gz
  2. cd mysql-5.1.50
  3. ./configure '--prefix=/usr/local/mysql' '--with-charset=utf8' '--with-extra-charsets=complex' '--with-pthread' '--enable-thread-safe-client' '--with-ssl' '--with-client-ldflags=-all-static' '--with-mysqld-ldflags=-all-static' '--with-plugins=partition,innobase,blackhole,myisam,innodb_plugin,heap,archive' '--enable-shared' '--enable-assembler'
  4. make
  5. make install
初始化数据库

点击(此处)折叠或打开

  1. /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/dbdata_3306 --user=mysql
  2. /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/dbdata_3307 --user=mysql
  3. /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/dbdata_3308 --user=mysql
创建配置文件
vim /data/dbdata_3306/my.cnf
3306的配置文件如下:

点击(此处)折叠或打开

  1. [client]
  2. port = 3306
  3. socket = /data/dbdata_3306/mysql.sock
  4. [mysqld]
  5. datadir=/data/dbdata_3306/
  6. skip-name-resolve
  7. lower_case_table_names=1
  8. innodb_file_per_table=1
  9. port = 3306
  10. socket = /data/dbdata_3306/mysql.sock
  11. back_log = 50
  12. max_connections = 300
  13. max_connect_errors = 1000
  14. table_open_cache = 2048
  15. max_allowed_packet = 16M
  16. binlog_cache_size = 2M
  17. max_heap_table_size = 64M
  18. sort_buffer_size = 2M
  19. join_buffer_size = 2M
  20. thread_cache_size = 64
  21. thread_concurrency = 8
  22. query_cache_size = 64M
  23. query_cache_limit = 2M
  24. ft_min_word_len = 4
  25. default-storage-engine = innodb
  26. thread_stack = 192K
  27. transaction_isolation = REPEATABLE-READ
  28. tmp_table_size = 64M
  29. log-bin=mysql-bin
  30. binlog_format=mixed
  31. slow_query_log
  32. long_query_time = 1
  33. server-id = 1
  34. key_buffer_size = 8M
  35. read_buffer_size = 2M
  36. read_rnd_buffer_size = 2M
  37. bulk_insert_buffer_size = 64M
  38. myisam_sort_buffer_size = 128M
  39. myisam_max_sort_file_size = 10G
  40. myisam_repair_threads = 1
  41. myisam_recover
  42. innodb_additional_mem_pool_size = 16M
  43. innodb_buffer_pool_size = 200M
  44. innodb_data_file_path = ibdata1:10M:autoextend
  45. innodb_file_io_threads = 8
  46. innodb_thread_concurrency = 16
  47. innodb_flush_log_at_trx_commit = 1
  48. innodb_log_buffer_size = 16M
  49. innodb_log_file_size = 512M
  50. innodb_log_files_in_group = 3
  51. innodb_max_dirty_pages_pct = 60
  52. innodb_lock_wait_timeout = 120
  53. [mysqldump]
  54. quick
  55. max_allowed_packet = 256M
  56. [mysql]
  57. no-auto-rehash
  58. prompt=\\u@\\d \\R:\\m>
  59. [myisamchk]
  60. key_buffer_size = 512M
  61. sort_buffer_size = 512M
  62. read_buffer = 8M
  63. write_buffer = 8M
  64. [mysqlhotcopy]
  65. interactive-timeout
  66. [mysqld_safe]
  67. open-files-limit = 8192
vim /data/dbdata_3307/my.cnf
3307的配置文件如下:

点击(此处)折叠或打开

  1. [client]
  2. port = 3307
  3. socket = /data/dbdata_3307/mysql.sock
  4. [mysqld]
  5. datadir=/data/dbdata_3307/
  6. skip-name-resolve
  7. lower_case_table_names=1
  8. innodb_file_per_table=1
  9. port = 3307
  10. socket = /data/dbdata_3307/mysql.sock
  11. back_log = 50
  12. max_connections = 300
  13. max_connect_errors = 1000
  14. table_open_cache = 2048
  15. max_allowed_packet = 16M
  16. binlog_cache_size = 2M
  17. max_heap_table_size = 64M
  18. sort_buffer_size = 2M
  19. join_buffer_size = 2M
  20. thread_cache_size = 64
  21. thread_concurrency = 8
  22. query_cache_size = 64M
  23. query_cache_limit = 2M
  24. ft_min_word_len = 4
  25. default-storage-engine = innodb
  26. thread_stack = 192K
  27. transaction_isolation = REPEATABLE-READ
  28. tmp_table_size = 64M
  29. log-bin=mysql-bin
  30. binlog_format=mixed
  31. slow_query_log
  32. long_query_time = 1
  33. server-id = 1
  34. key_buffer_size = 8M
  35. read_buffer_size = 2M
  36. read_rnd_buffer_size = 2M
  37. bulk_insert_buffer_size = 64M
  38. myisam_sort_buffer_size = 128M
  39. myisam_max_sort_file_size = 10G
  40. myisam_repair_threads = 1
  41. myisam_recover
  42. innodb_additional_mem_pool_size = 16M
  43. innodb_buffer_pool_size = 200M
  44. innodb_data_file_path = ibdata1:10M:autoextend
  45. innodb_file_io_threads = 8
  46. innodb_thread_concurrency = 16
  47. innodb_flush_log_at_trx_commit = 1
  48. innodb_log_buffer_size = 16M
  49. innodb_log_file_size = 512M
  50. innodb_log_files_in_group = 3
  51. innodb_max_dirty_pages_pct = 60
  52. innodb_lock_wait_timeout = 120
  53. [mysqldump]
  54. quick
  55. max_allowed_packet = 256M
  56. [mysql]
  57. no-auto-rehash
  58. prompt=\\u@\\d \\R:\\m>
  59. [myisamchk]
  60. key_buffer_size = 512M
  61. sort_buffer_size = 512M
  62. read_buffer = 8M
  63. write_buffer = 8M
  64. [mysqlhotcopy]
  65. interactive-timeout
  66. [mysqld_safe]
  67. open-files-limit = 8192
vim /data/dbdata_3308/my.cnf
3308的配置文件如下:
 

点击(此处)折叠或打开

  1. [client]
  2. port = 3308
  3. socket = /data/dbdata_3308/mysql.sock
  4. [mysqld]
  5. datadir=/data/dbdata_3308/
  6. skip-name-resolve
  7. lower_case_table_names=1
  8. innodb_file_per_table=1
  9. port = 3308
  10. socket = /data/dbdata_3308/mysql.sock
  11. back_log = 50
  12. max_connections = 300
  13. max_connect_errors = 1000
  14. table_open_cache = 2048
  15. max_allowed_packet = 16M
  16. binlog_cache_size = 2M
  17. max_heap_table_size = 64M
  18. sort_buffer_size = 2M
  19. join_buffer_size = 2M
  20. thread_cache_size = 64
  21. thread_concurrency = 8
  22. query_cache_size = 64M
  23. query_cache_limit = 2M
  24. ft_min_word_len = 4
  25. default-storage-engine = innodb
  26. thread_stack = 192K
  27. transaction_isolation = REPEATABLE-READ
  28. tmp_table_size = 64M
  29. log-bin=mysql-bin
  30. binlog_format=mixed
  31. slow_query_log
  32. long_query_time = 1
  33. server-id = 1
  34. key_buffer_size = 8M
  35. read_buffer_size = 2M
  36. read_rnd_buffer_size = 2M
  37. bulk_insert_buffer_size = 64M
  38. myisam_sort_buffer_size = 128M
  39. myisam_max_sort_file_size = 10G
  40. myisam_repair_threads = 1
  41. myisam_recover
  42. innodb_additional_mem_pool_size = 16M
  43. innodb_buffer_pool_size = 200M
  44. innodb_data_file_path = ibdata1:10M:autoextend
  45. innodb_file_io_threads = 8
  46. innodb_thread_concurrency = 16
  47. innodb_flush_log_at_trx_commit = 1
  48. innodb_log_buffer_size = 16M
  49. innodb_log_file_size = 512M
  50. innodb_log_files_in_group = 3
  51. innodb_max_dirty_pages_pct = 60
  52. innodb_lock_wait_timeout = 120
  53. [mysqldump]
  54. quick
  55. max_allowed_packet = 256M
  56. [mysql]
  57. no-auto-rehash
  58. prompt=\\u@\\d \\R:\\m>
  59. [myisamchk]
  60. key_buffer_size = 512M
  61. sort_buffer_size = 512M
  62. read_buffer = 8M
  63. write_buffer = 8M
  64. [mysqlhotcopy]
  65. interactive-timeout
  66. [mysqld_safe]
  67. open-files-limit = 8192

创建自动启动文件
vim /data/dbdata_3306/mysqld
3306的启动文件如下:

点击(此处)折叠或打开

  1. #!/bin/bash
  2. mysql_port=3306
  3. mysql_username="admin"
  4. mysql_password="password"
  5. function_start_mysql()
  6. {
  7. printf "Starting MySQL...\n"
  8. /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/dbdata_${mysql_port}/my.cnf 2>&1 > /dev/null &
  9. }
  10. function_stop_mysql()
  11. {
  12. printf "Stoping MySQL...\n"
  13. /usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /data/dbdata_${mysql_port}/mysql.sock shutdown
  14. }
  15. function_restart_mysql()
  16. {
  17. printf "Restarting MySQL...\n"
  18. function_stop_mysql
  19. function_start_mysql
  20. }
  21. function_kill_mysql()
  22. {
  23. kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
  24. kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
  25. }
  26. case $1 in
  27. start)
  28. function_start_mysql;;
  29. stop)
  30. function_stop_mysql;;
  31. kill)
  32. function_kill_mysql;;
  33. restart)
  34. function_stop_mysql
  35. function_start_mysql;;
  36. *)
  37. echo "Usage: /data/dbdata_${mysql_port}/mysqld {start|stop|restart|kill}";;
  38. esac
vim /data/dbdata_3307/mysqld
3307的启动文件如下:

点击(此处)折叠或打开

  1. #!/bin/bash
  2. mysql_port=3307
  3. mysql_username="admin"
  4. mysql_password="password"
  5. function_start_mysql()
  6. {
  7. printf "Starting MySQL...\n"
  8. /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/dbdata_${mysql_port}/my.cnf 2>&1 > /dev/null &
  9. }
  10. function_stop_mysql()
  11. {
  12. printf "Stoping MySQL...\n"
  13. /usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /data/dbdata_${mysql_port}/mysql.sock shutdown
  14. }
  15. function_restart_mysql()
  16. {
  17. printf "Restarting MySQL...\n"
  18. function_stop_mysql
  19. function_start_mysql
  20. }
  21. function_kill_mysql()
  22. {
  23. kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
  24. kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
  25. }
  26. case $1 in
  27. start)
  28. function_start_mysql;;
  29. stop)
  30. function_stop_mysql;;
  31. kill)
  32. function_kill_mysql;;
  33. restart)
  34. function_stop_mysql
  35. function_start_mysql;;
  36. *)
  37. echo "Usage: /data/dbdata_${mysql_port}/mysqld {start|stop|restart|kill}";;
  38. esac
vim /data/dbdata_3308/mysqld
3308的启动文件如下:

点击(此处)折叠或打开

  1. #!/bin/bash
  2. mysql_port=3308
  3. mysql_username="admin"
  4. mysql_password="password"
  5. function_start_mysql()
  6. {
  7. printf "Starting MySQL...\n"
  8. /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/dbdata_${mysql_port}/my.cnf 2>&1 > /dev/null &
  9. }
  10. function_stop_mysql()
  11. {
  12. printf "Stoping MySQL...\n"
  13. /usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /data/dbdata_${mysql_port}/mysql.sock shutdown
  14. }
  15. function_restart_mysql()
  16. {
  17. printf "Restarting MySQL...\n"
  18. function_stop_mysql
  19. function_start_mysql
  20. }
  21. function_kill_mysql()
  22. {
  23. kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
  24. kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
  25. }
  26. case $1 in
  27. start)
  28. function_start_mysql;;
  29. stop)
  30. function_stop_mysql;;
  31. kill)
  32. function_kill_mysql;;
  33. restart)
  34. function_stop_mysql
  35. function_start_mysql;;
  36. *)
  37. echo "Usage: /data/dbdata_${mysql_port}/mysqld {start|stop|restart|kill}";;
  38. esac
启动3306、3307、3308的mysql

点击(此处)折叠或打开

  1. /data/dbdata_3306/mysqld start
  2. /data/dbdata_3307/mysqld start
  3. /data/dbdata_3308/mysqld start

更改原来密码(处于安全考虑,还需要删除系统中没有密码的帐号,这里省略了):
 

点击(此处)折叠或打开

  1. /usr/local/mysql/bin/mysqladmin -uroot password 'password' -S /data/dbdata_3306/mysql.sock
  2. /usr/local/mysql/bin/mysqladmin -uroot password 'password' -S /data/dbdata_3307/mysql.sock
  3. /usr/local/mysql/bin/mysqladmin -uroot password 'password' -S /data/dbdata_3308/mysql.sock
登录测试并创建关闭mysql的帐号权限,mysqld脚本要用到!
 

点击(此处)折叠或打开

  1. /usr/local/mysql/bin/mysql -uroot -ppassword -S /data/dbdata_3308/mysql.sock
  2. GRANT SHUTDOWN ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password';
  3. flush privileges;
  4. /usr/local/mysql/bin/mysql -uroot -ppassword -S /data/dbdata_3308/mysql.sock
  5. GRANT SHUTDOWN ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password';
  6. flush privileges;
  7. /usr/local/mysql/bin/mysql -uroot -ppassword -S /data/dbdata_3308/mysql.sock
  8. GRANT SHUTDOWN ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password';
  9. flush privileges;
创建了admin帐号以后脚本的stop功能和restart功能就正常了!
更改环境变量
 

点击(此处)折叠或打开

  1. vim /etc/profile 添加下面一行内容
  2. PATH=${PATH}:/usr/local/mysql/bin/
  3. source /etc/profile
添加到自动启动
 

点击(此处)折叠或打开

  1. vim /etc/init.d/boot.local
  2. /data/dbdata_3306/mysqld start
  3. /data/dbdata_3307/mysqld start
  4. /data/dbdata_3308/mysqld start
如果是rhel或者centos系统的话自启动文件/etc/rc.local
 
管理的话,在本地都是采用 -S /data/dbdata_3308/mysql.sock,如果在远程可以通过不同的端口连接上去坐管理操作。其他的和单实例的管理没什么区别!
 
 
 
再来看第二种通过官方自带的mysqld_multi来实现多实例实战:
这里的mysql安装以及数据库的初始化和前面的步骤一样,就不再赘述。

mysqld_multi的配置
vim /etc/my.cnf

点击(此处)折叠或打开

  1. [mysqld_multi]
  2. mysqld = /usr/local/mysql/bin/mysqld_safe
  3. mysqladmin = /usr/local/mysql/bin/mysqladmin
  4. user = admin
  5. password = password
  6. [mysqld1]
  7. socket = /data/dbdata_3306/mysql.sock
  8. port = 3306
  9. pid-file = /data/dbdata_3306/3306.pid
  10. datadir = /data/dbdata_3306
  11. user = mysql
  12. skip-name-resolve
  13. lower_case_table_names=1
  14. innodb_file_per_table=1
  15. back_log = 50
  16. max_connections = 300
  17. max_connect_errors = 1000
  18. table_open_cache = 2048
  19. max_allowed_packet = 16M
  20. binlog_cache_size = 2M
  21. max_heap_table_size = 64M
  22. sort_buffer_size = 2M
  23. join_buffer_size = 2M
  24. thread_cache_size = 64
  25. thread_concurrency = 8
  26. query_cache_size = 64M
  27. query_cache_limit = 2M
  28. ft_min_word_len = 4
  29. default-storage-engine = innodb
  30. thread_stack = 192K
  31. transaction_isolation = REPEATABLE-READ
  32. tmp_table_size = 64M
  33. log-bin=mysql-bin
  34. binlog_format=mixed
  35. slow_query_log
  36. long_query_time = 1
  37. server-id = 1
  38. key_buffer_size = 8M
  39. read_buffer_size = 2M
  40. read_rnd_buffer_size = 2M
  41. bulk_insert_buffer_size = 64M
  42. myisam_sort_buffer_size = 128M
  43. myisam_max_sort_file_size = 10G
  44. myisam_repair_threads = 1
  45. myisam_recover
  46. innodb_additional_mem_pool_size = 16M
  47. innodb_buffer_pool_size = 200M
  48. innodb_data_file_path = ibdata1:10M:autoextend
  49. innodb_file_io_threads = 8
  50. innodb_thread_concurrency = 16
  51. innodb_flush_log_at_trx_commit = 1
  52. innodb_log_buffer_size = 16M
  53. innodb_log_file_size = 512M
  54. innodb_log_files_in_group = 3
  55. innodb_max_dirty_pages_pct = 60
  56. innodb_lock_wait_timeout = 120
  57. [mysqld2]
  58. socket = /data/dbdata_3307/mysql.sock
  59. port = 3307
  60. pid-file = /data/dbdata_3307/3307.pid
  61. datadir = /data/dbdata_3307
  62. user = mysql
  63. skip-name-resolve
  64. lower_case_table_names=1
  65. innodb_file_per_table=1
  66. back_log = 50
  67. max_connections = 300
  68. max_connect_errors = 1000
  69. table_open_cache = 2048
  70. max_allowed_packet = 16M
  71. binlog_cache_size = 2M
  72. max_heap_table_size = 64M
  73. sort_buffer_size = 2M
  74. join_buffer_size = 2M
  75. thread_cache_size = 64
  76. thread_concurrency = 8
  77. query_cache_size = 64M
  78. query_cache_limit = 2M
  79. ft_min_word_len = 4
  80. default-storage-engine = innodb
  81. thread_stack = 192K
  82. transaction_isolation = REPEATABLE-READ
  83. tmp_table_size = 64M
  84. log-bin=mysql-bin
  85. binlog_format=mixed
  86. slow_query_log
  87. long_query_time = 1
  88. server-id = 1
  89. key_buffer_size = 8M
  90. read_buffer_size = 2M
  91. read_rnd_buffer_size = 2M
  92. bulk_insert_buffer_size = 64M
  93. myisam_sort_buffer_size = 128M
  94. myisam_max_sort_file_size = 10G
  95. myisam_repair_threads = 1
  96. myisam_recover
  97. innodb_additional_mem_pool_size = 16M
  98. innodb_buffer_pool_size = 200M
  99. innodb_data_file_path = ibdata1:10M:autoextend
  100. innodb_file_io_threads = 8
  101. innodb_thread_concurrency = 16
  102. innodb_flush_log_at_trx_commit = 1
  103. innodb_log_buffer_size = 16M
  104. innodb_log_file_size = 512M
  105. innodb_log_files_in_group = 3
  106. innodb_max_dirty_pages_pct = 60
  107. innodb_lock_wait_timeout = 120
  108. [mysqld3]
  109. socket = /data/dbdata_3308/mysql.sock
  110. port = 3308
  111. pid-file = /data/dbdata_3308/3308.pid
  112. datadir = /data/dbdata_3308
  113. user = mysql
  114. skip-name-resolve
  115. lower_case_table_names=1
  116. innodb_file_per_table=1
  117. back_log = 50
  118. max_connections = 300
  119. max_connect_errors = 1000
  120. table_open_cache = 2048
  121. max_allowed_packet = 16M
  122. binlog_cache_size = 2M
  123. max_heap_table_size = 64M
  124. sort_buffer_size = 2M
  125. join_buffer_size = 2M
  126. thread_cache_size = 64
  127. thread_concurrency = 8
  128. query_cache_size = 64M
  129. query_cache_limit = 2M
  130. ft_min_word_len = 4
  131. default-storage-engine = innodb
  132. thread_stack = 192K
  133. transaction_isolation = REPEATABLE-READ
  134. tmp_table_size = 64M
  135. log-bin=mysql-bin
  136. binlog_format=mixed
  137. slow_query_log
  138. long_query_time = 1
  139. server-id = 1
  140. key_buffer_size = 8M
  141. read_buffer_size = 2M
  142. read_rnd_buffer_size = 2M
  143. bulk_insert_buffer_size = 64M
  144. myisam_sort_buffer_size = 128M
  145. myisam_max_sort_file_size = 10G
  146. myisam_repair_threads = 1
  147. myisam_recover
  148. innodb_additional_mem_pool_size = 16M
  149. innodb_buffer_pool_size = 200M
  150. innodb_data_file_path = ibdata1:10M:autoextend
  151. innodb_file_io_threads = 8
  152. innodb_thread_concurrency = 16
  153. innodb_flush_log_at_trx_commit = 1
  154. innodb_log_buffer_size = 16M
  155. innodb_log_file_size = 512M
  156. innodb_log_files_in_group = 3
  157. innodb_max_dirty_pages_pct = 60
  158. innodb_lock_wait_timeout = 120
  159. [mysqldump]
  160. quick
  161. max_allowed_packet = 256M
  162. [mysql]
  163. no-auto-rehash
  164. prompt=\\u@\\d \\R:\\m>
  165. [myisamchk]
  166. key_buffer_size = 512M
  167. sort_buffer_size = 512M
  168. read_buffer = 8M
  169. write_buffer = 8M
  170. [mysqlhotcopy]
  171. interactive-timeout
  172. [mysqld_safe]
  173. open-files-limit = 8192
mysqld_multi启动
 

点击(此处)折叠或打开

  1. /usr/local/mysql/bin/mysqld_multi start 1
  2. /usr/local/mysql/bin/mysqld_multi start 2
  3. /usr/local/mysql/bin/mysqld_multi start 3
或者采用一条命令的形式:
 

点击(此处)折叠或打开

  1. /usr/local/mysql/bin/mysqld_multi start 1-3
更改原来密码(处于安全考虑,还需要删除系统中没有密码的帐号,这里省略了):

点击(此处)折叠或打开

  1. /usr/local/mysql/bin/mysqladmin -uroot password 'password' -S /data/dbdata_3306/mysql.sock
  2. /usr/local/mysql/bin/mysqladmin -uroot password 'password' -S /data/dbdata_3307/mysql.sock
  3. /usr/local/mysql/bin/mysqladmin -uroot password 'password' -S /data/dbdata_3308/mysql.sock
 
登录测试并创建admin密码(停止mysql的时候需要使用到)

点击(此处)折叠或打开

  1. /usr/local/mysql/bin/mysql -uroot -ppassword -S /data/dbdata_3308/mysql.sock
  2. GRANT SHUTDOWN ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password';
  3. flush privileges;
  4. /usr/local/mysql/bin/mysql -uroot -ppassword -S /data/dbdata_3308/mysql.sock
  5. GRANT SHUTDOWN ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password';
  6. flush privileges;
  7. /usr/local/mysql/bin/mysql -uroot -ppassword -S /data/dbdata_3308/mysql.sock
  8. GRANT SHUTDOWN ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password';
  9. flush privileges;
更改环境变量

点击(此处)折叠或打开

  1. vim /etc/profile
  2. PATH=${PATH}:/usr/local/mysql/bin/
  3. source /etc/profile
添加到自动启动

点击(此处)折叠或打开

  1. vim /etc/init.d/boot.local
  2. /usr/local/mysql/bin/mysqld_multi start 1-3
如果是rhel或者centos系统的话自启动文件/etc/rc.local
 
管理的话,在本地都是采用 -S /data/dbdata_3308/mysql.sock,如果在远程可以通过不同的端口连接上去坐管理操作。其他的和单实例的管理没什么区别!
大家在管理多实例的话可以使用mysqlmanager实例管理器,管理器来会比较方面,限于篇幅,这里就不在多做介绍!
posted @ 2015-10-09 10:56  鸾舞春秋  阅读(254)  评论(0编辑  收藏  举报