首页 / MYSQL / Mysql5.6多实例部署
Mysql5.6多实例部署
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Mysql5.6多实例部署,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4240字,纯文字阅读大概需要7分钟。
内容图文
![Mysql5.6多实例部署](/upload/InfoBanner/zyjiaocheng/917/7ff35ebae5d94344b979429957930302.jpg)
MySQL-5.6.29多实例部署
一,mysql-5.6.29源码安装步骤:
1,安装需要的软件
[root@localhost ~]#yum -y install gcc gcc-c++ make ncurses ncurses-devel cmake cmake
2,源码安装mysql-5.6.29
2.1)创建用户和组并创建数据存放目录
[root@localhost ~]#groupadd mysql [root@localhost ~]#useradd mysql -s /sbin/nologin -M -g mysql [root@localhost mysql-5.6.29]# mkdir -p /data/mysql_3306 [root@localhost mysql-5.6.29]# mkdir -p /data/mysql_3308
2.2)给数据库配置环境变量
[root@localhost mysql-5.6.29]# echo"export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib" >>/etc/profile [root@localhost mysql-5.6.29]#source /etc/profile [root@localhost mysql-5.6.29]#echo $PATH
2.3)解压安装mysql-5.6.29
[root@localhost ~]#tar xf mysql-5.6.29.tar.gz [root@localhost mysql-5.6.29]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \ -DENABLED_LOCAL_INFILE=ON \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITHOUT_PARTITION_STORAGE_ENGINE=0 \ -DWITH_FAST_MUTEXES=1 \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DWITH_DEBUG=0 [root@localhost mysql-5.6.29]# make [root@localhost mysql-5.6.29]# make install
3,配置数据库
3.1)配置文件my.cnf文件
[root@localhost mysql-5.6.29]#vim /etc/my.cnf [root@mysqldb bin]# cat /etc/my.cnf [client] #port = 3306 #socket = /tmp/mysql.sock [mysqld3306] port = 3306 basedir = /usr/local/mysql datadir = /data/mysql_3306 socket = /tmp/mysql_3306.sock slow_query_log_file = /data/mysql_3306/slow.log log-error = /data/mysql_3306/error.log log-bin = /data/mysql_3306/mysql-bin sync_binlog = 1 binlog_cache_size = 4M default-storage-engine = InnoDB binlog_format = row transaction_isolation = REPEATABLE-READ innodb_buffer_pool_size = 100m [mysql] [mysqld3308] port = 3308 basedir = /usr/local/mysql datadir = /data/mysql_3308 socket = /tmp/mysql_3308.sock slow_query_log_file = /data/mysql_3308/slow.log log-error = /data/mysql_3308/error.log log-bin = /data/mysql_3308/mysql-bin sync_binlog = 1 binlog_cache_size = 4M default-storage-engine = InnoDB binlog_format = row transaction_isolation = REPEATABLE-READ innodb_buffer_pool_size = 100m [mysqld_multi] mysqld=/usr/local/mysql/bin/mysqld_safe mysqladmin=/usr/local/mysql/bin/mysqladmin [mysqldump] quick max_allowed_packet = 32M
3.2)初始化数据库文件
[root@mysqldb ~]# cd /usr/local/mysql/scripts/ [root@mysqldb scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3306 --defaults-file=/etc/my.cnf --user=mysql [root@mysqldb scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3308 --defaults-file=/etc/my.cnf --user=mysql
3.3)多实例采用mysqld_multi来启停数据库
[root@mysqldb bin]# ./mysqld_multi --defaults-file=/etc/my.cnf --user=root --password=MANAGER start 3306,3308
3.4)查看多实例运行的状态
[root@mysqldb bin]# ./mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld3306 is running MySQL server from group: mysqld3308 is running
4,登录数据库操作
4.1)登录数据库是没有密码,因此需要修改密码
[root@mysqldb bin]# mysql -uroot -p -P3306 -h 127.0.0.1 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.6.29-log Source distribution Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use mysql; mysql>UPDATE user SET password=PASSWORD('hwg123') WHERE user='root'; mysql>FLUSH PRIVILEGES; [root@mysqldb bin]# mysql -uroot -p -P3308 -h 127.0.0.1 mysql> use mysql; mysql>UPDATE user SET password=PASSWORD('hwg123') WHERE user='root'; mysql>FLUSH PRIVILEGES;
4.2)授权某个网段ip登录到本机
mysql> create database db01; mysql> create user tony@localhost identified by 'hwg123'; mysql> grant all on db01.* to 'tony'@'10.93.58.%'identified by 'hwg123'WITH GRANT OPTION; mysql> flush privileges;
内容总结
以上是互联网集市为您收集整理的Mysql5.6多实例部署全部内容,希望文章能够帮你解决Mysql5.6多实例部署所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。