首页 / MYSQL / MySQL5.6多实例安装
MySQL5.6多实例安装
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MySQL5.6多实例安装,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含8622字,纯文字阅读大概需要13分钟。
内容图文
![MySQL5.6多实例安装](/upload/InfoBanner/zyjiaocheng/475/99c91bc8cc36431eb3998415eb23e60e.jpg)
prot = 3306socket = /data/3306/mysql.sock [mysql] no-auto-rehash [mysqld] ## 服务端配置文件user = mysql ## mysql启动用户port = 3306 ## 监听端口号socket = /data/3306/mysql.sock ## 指定sock路径basedir = /usr/local/mysql-5.6 ## 数据库安装路径datadir = /data/3306/data ## 数据存放目录open_files_limit = 1024back_log = 600max_connections = 800max_connect_errors = 3000table_cache = 614external-locking = FALSE max_allowed_packet = 8M sort_buffer_size = 1M join_buffer_size = 1M thread_cache_size = 100thread_concurrency = 2query_cache_size = 2M query_cache_limit = 2M query_cache_min_res_unit = 2k#default_table_type = InnoDBthread_stack = 192K#transaction_isolation = READ-COMMITTEDtmp_table_size = 2M max_heap_table_size = 2M long_query_time = 1log-error = /data/3306/error.logslow-query-log-file = /data/3306/slow.logpid-file = /data/3306/mysql.pidlog-bin = /data/3306/mysql-bin relay-log = /data/3306/relay-bin relay-log-info-file = /data/3306/relay-log.info binlog_cache_size = 1M max_binlog_cache_size = 1M max_binlog_size = 2M expire_logs_days = 7key_buffer_size = 16M read_buffer_size = 1M read_rnd_buffer_size = 1M bulk_insert_buffer_size = 1M#myisam_sort_buffer_size = 1M#myisam_max_sort_file_size = 10G#myisam_max_extra_sort_file_size = 10G#myisam_repair_threads = 1#myisam_recover lower_case_table_names = 1skip-name-resolve slave-skip-errors = 1032,1062replicate-ignore-db = mysql server-id = 1 #innodb_additional_mem_pool_size = 4M#innodb_buffer_pool_size = 23M#innodb_data_file_path = ibdata1:128M:autoextend#innodb_file_io_threads = 4#innodb_thread_concurrency = 8#innodb_flush_log_at_trx_commit = 2#innodb_log_buffer_size = 2M#innodb_log_file_size = 4M#innodb_log_files_in_group = 3#innodb_max_dirty_pages_pct = 90#innodb_lock_wait_timeout = 120#innodb_file_per_table = 0 [mysqldump] quick max_allowed_packet = 2M [mysqld_safe]log-error = /data/3306/mysql_90root3306.err pid-file = /data/3306/mysql.pid
3307 配置文件
[root@mysql5.6 ~]# vim /data/3307/my.cnf[client] prot = 3307socket = /data/3307/mysql.sock [mysql] no-auto-rehash [mysqld] user = mysql port = 3307socket = /data/3307/mysql.sock basedir = /usr/local/mysql datadir = /data/3307/data open_files_limit = 1024back_log = 600max_connections = 800max_connect_errors = 3000#table_cache = 614external-locking = FALSE max_allowed_packet = 8M sort_buffer_size = 1M join_buffer_size = 1M thread_cache_size = 100thread_concurrency = 2query_cache_size = 2M query_cache_limit = 2M query_cache_min_res_unit = 2k#default_table_type = InnoDBthread_stack = 192K#transaction_isolation = READ-COMMITTEDtmp_table_size = 2M max_heap_table_size = 2M long_query_time = 1log-error = /data/3307/error.logslow-query-log-file = /data/3307/slow.logpid-file = /data/3307/mysql.pidlog-bin = /data/3307/mysql-bin relay-log = /data/3307/relay-bin relay-log-info-file = /data/3307/relay-log.info binlog_cache_size = 1M max_binlog_cache_size = 1M max_binlog_size = 2M expire_logs_days = 7key_buffer_size = 16M read_buffer_size = 1M read_rnd_buffer_size = 1M bulk_insert_buffer_size = 1M#myisam_sort_buffer_size = 1M#myisam_max_sort_file_size = 10G#myisam_max_extra_sort_file_size = 10G#myisam_repair_threads = 1#myisam_recover lower_case_table_names = 1skip-name-resolve slave-skip-errors = 1032,1062replicate-ignore-db = mysql server-id = 2 #innodb_additional_mem_pool_size = 4M#innodb_buffer_pool_size = 23M#innodb_data_file_path = ibdata1:1200M:autoextend#innodb_file_io_threads = 4#innodb_thread_concurrency = 8#innodb_flush_log_at_trx_commit = 2#innodb_log_buffer_size = 2M#innodb_log_file_size = 200M#innodb_log_files_in_group = 3#innodb_max_dirty_pages_pct = 90#innodb_lock_wait_timeout = 120#innodb_file_per_table = 0 [mysqldump] quick max_allowed_packet = 2M [mysqld_safe]log-error = /data/3307/mysql_90root3307.err pid-file = /data/3307/mysql.pid
6.配置MySQL命令 全局路径
[root@mysql5.6 ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile[root@mysql5.6 ~]# source /etc/profile
7.初始化数据库
[root@mysql5.6 ~]# cd /usr/local/mysql/scripts/[root@mysql5.6 scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/3306/data/ --user=mysql[root@mysql5.6 scripts]# echo $?0[root@mysql5.6 scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/3307/data/ --user=mysql[root@mysql5.6 scripts]# echo $?0
8.多实例服务 启动和停止命令
启动命令
[root@mysql5.6 ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/3306/my.cnf 2>&1 [root@mysql5.6 ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf 2>&1 >
停止命令
[root@mysql5.6 ~]# /usr/local/mysql/bin/mysqladmin -uroot -p -S /data/3306/mysql.sock shutdown [root@mysql5.6 ~]# /usr/local/mysql/bin/mysqladmin -uroot -p -S /data/3307/mysql.sock shutdown
查看服务启动状态
[root@mysql5.6 ~]# netstat -anpt|grep mysqltcp 0 0 :::3306 :::* LISTEN 20886/mysqld tcp 0 0 :::3307 :::* LISTEN 20045/mysqld
三、进入MySQL
1.进入MySQL(3306,3307)数据库
[root@mysql5.6 ~]# mysql -uroot -p -S /data/3306/mysql.sockmysql> show variables like ‘port‘; +---------------+-------+| Variable_name | Value | +---------------+-------+| port | 3306 | +---------------+-------+[root@mysql5.6 ~]# mysql -uroot -p -S /data/3307/mysql.sockmysql> show variables like ‘port‘; +---------------+-------+| Variable_name | Value | +---------------+-------+| port | 3307 | +---------------+-------+
2.更改root密码
mysql> update mysql.user set password=passwort(‘newpass‘) where user=‘root‘; mysql> flush privileges
四、编写启动脚本
3306启动脚本
[root@mysql5.6 ~]# vim /data/3306/mysql#!/bin/bash# initport=3306mysql_user="root"mysql_pwd=""CmdPath="/usr/local/mysql/bin"mysql_sock="/data/${port}/mysql.sock" # Startup functionfunction_start_mysql(){ if [ ! -e "$mysql_sock" ];then printf "Starting MySQL... \n" /bin/sh ${CmdPath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2>&1 > /dev/null & else printf "MySQL is running...\n" exit fi} # Stop functionfunction_stop_mysql(){ if [ ! -e "$mysql_sock" ];then printf "MySQL is stopped...\n" exit else printf "Stoping MySQL...\n" ${CmdPath}/mysqladmin -u ${mysql_user} -p ${mysql_pwd} -S /data/${port}/mysql.sock shutdown fi} # Restart functionfunction_restart_mysql(){ printf "Restarting MySQL...\n" function_stop_mysql sleep 2 function_start_mysql } case $1 instart) function_start_mysql ;; restart) function_restart_mysql ;; stop) function_stop_mysql ;; *) echo "/data/${port}/mysql {start|restart|stop}" ;;esac
3307启动脚本
#!/bin/bash# initport=3307mysql_user="root"mysql_pwd=""CmdPath="/usr/local/mysql/bin"mysql_sock="/data/${port}/mysql.sock" # Startup functionfunction_start_mysql(){ if [ ! -e "$mysql_sock" ];then printf "Starting MySQL... \n" /bin/sh ${CmdPath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2>&1 > /dev/null & else printf "MySQL is running...\n" exit fi} # Stop functionfunction_stop_mysql(){ if [ ! -e "$mysql_sock" ];then printf "MySQL is stopped...\n" exit else printf "Stoping MySQL...\n" ${CmdPath}/mysqladmin -u ${mysql_user} -p ${mysql_pwd} -S /data/${port}/mysql.sock shutdown fi} # Restart functionfunction_restart_mysql(){ printf "Restarting MySQL...\n" function_stop_mysql sleep 2 function_start_mysql } case $1 instart) function_start_mysql ;; restart) function_restart_mysql ;; stop) function_stop_mysql ;; *) echo "/data/${port}/mysql {start|restart|stop}" ;;esac
MySQL5.6多实例安装
标签:linux mysql 安装 多实例 编译
本文系统来源:http://dahui09.blog.51cto.com/10693267/1898166
内容总结
以上是互联网集市为您收集整理的MySQL5.6多实例安装全部内容,希望文章能够帮你解决MySQL5.6多实例安装所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。