mysql-5.6安装
一、下载解压mysql5.6二进制文件社区版本
root@renmaitong bjia]# tar zxvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz -c /usr/local/
二、创建软连接
ln -s mysql-5.6.23-linux-glibc2.5-x86_64/ mysql
三、创建mysql用户和用户组
[root@renmaitong~]# groupadd mysql [root@renmaitong ~]# useradd -r -s /sbin/nologin -g mysql mysql
四、mysql数据库初始化
[root@renmaitong bjia]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/4001/ --user=mysql [root@renmaitong bjia]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/4003/ --user=mysql
五、配置mysql多实例my.cnf
[mysqld_multi] mysqld = /usr/local/mysql/bin/mysqld_safe mysqladmin = /usr/local/mysql/bin/mysqladmin #user = your_user #password = your_password [mysqld1] server-id = 4100 relay-log =/usr/local/mysql/4001_log/relay-log basedir = /usr/local/mysql datadir = /usr/local/mysql/data/4001 port = 4001 socket = /tmp/mysql4001.sock #log_bin_trust_function_creators=1 #log-bin=/usr/local/mysql/3003_log/mysql-bin #binlog_format=mixed #binlog_cache_size = 32M expire_logs_days = 3 sync-binlog = 1 innodb_flush_log_at_trx_commit = 1 innodb_data_file_path = ibdata1:12M:autoextend innodb_log_files_in_group = 2 innodb_log_file_size = 512M [mysqld2] server-id = 4200 relay-log =/usr/local/mysql/4003_log/relay-log basedir = /usr/local/mysql datadir = /usr/local/mysql/data/4003 port = 4003 socket = /tmp/mysql4003.sock #log_bin_trust_function_creators=1 #log-bin=/usr/local/mysql/3003_log/mysql-bin #binlog_format=mixed #binlog_cache_size = 32M expire_logs_days = 3 sync-binlog = 1 innodb_flush_log_at_trx_commit = 1 innodb_data_file_path = ibdata1:12M:autoextend innodb_log_files_in_group = 2 innodb_log_file_size = 512M
六、配置mysql多实例启动脚本
[root@renmaitong mysql]# cp /usr/local/mysql/bin/mysqld_multi /usr/bin/
七、授权
[root@renmaitong mysql]# chown -R mysql.mysql /usr/local/mysql/data/4001/ [root@renmaitong mysql]# chown -R mysql.mysql /usr/local/mysql/data/4003/ [root@renmaitong mysql]# mkdir /usr/local/mysql/4001_log [root@renmaitong mysql]# mkdir /usr/local/mysql/4003_log [root@renmaitong mysql]# chown -R mysql.mysql /usr/local/mysql/4001_log [root@renmaitong mysql]# chown -R mysql.mysql /usr/local/mysql/4003_log
八、启动数据库
[root@renmaitong mysql]# mysqld_multi start 1-2
九、查看日志和服务
[root@renmaitong 4003]# tail -f renmaitong.err 2015-05-12 16:52:32 24418 [Note] InnoDB: Waiting for purge to start 2015-05-12 16:52:32 24418 [Note] InnoDB: 5.6.23 started; log sequence number 1625987 2015-05-12 16:52:32 24418 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3a6ad7f2-f884-11e4-9cb9-f01fafda7a2d. 2015-05-12 16:52:32 24418 [Note] Server hostname (bind-address): ‘*‘; port: 4003 2015-05-12 16:52:32 24418 [Note] IPv6 is not available. 2015-05-12 16:52:32 24418 [Note] - ‘0.0.0.0‘ resolves to ‘0.0.0.0‘; 2015-05-12 16:52:32 24418 [Note] Server socket created on IP: ‘0.0.0.0‘. 2015-05-12 16:52:32 24418 [Note] Event Scheduler: Loaded 0 events 2015-05-12 16:52:32 24418 [Note] /usr/local/mysql/bin/mysqld: ready for connections. Version: ‘5.6.23‘ socket: ‘/tmp/mysql4003.sock‘ port: 4003 MySQL Community Server (GPL) [root@renmaitong 4001]# tail -f renmaitong.err 2015-05-12 16:52:32 24419 [Note] InnoDB: Waiting for purge to start 2015-05-12 16:52:32 24419 [Note] InnoDB: 5.6.23 started; log sequence number 1625987 2015-05-12 16:52:32 24419 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3a5ef2c0-f884-11e4-9cb9-f01fafda7a2d. 2015-05-12 16:52:32 24419 [Note] Server hostname (bind-address): ‘*‘; port: 4001 2015-05-12 16:52:32 24419 [Note] IPv6 is not available. 2015-05-12 16:52:32 24419 [Note] - ‘0.0.0.0‘ resolves to ‘0.0.0.0‘; 2015-05-12 16:52:32 24419 [Note] Server socket created on IP: ‘0.0.0.0‘. 2015-05-12 16:52:32 24419 [Note] Event Scheduler: Loaded 0 events 2015-05-12 16:52:32 24419 [Note] /usr/local/mysql/bin/mysqld: ready for connections. Version: ‘5.6.23‘ socket: ‘/tmp/mysql4001.sock‘ port: 4001 MySQL Community Server (GPL) 说明服务器已经起来了
十、登录数据库
[root@renmaitong 4001]# mysql -uroot -S /tmp/mysql4001.sock [root@renmaitong 4001]# mysql -uroot -S /tmp/mysql4003.sock
十一、停止数据库
[root@renmaitong 4001]# mysqladmin -u root -S /tmp/mysql4001.sock shutdown [root@renmaitong 4001]# mysqladmin -u root -S /tmp/mysql4003.sock shutdown
本文出自 “奋斗中的老兵” 博客,请务必保留此出处http://jiaxu201.blog.51cto.com/4569604/1650707
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。