mysql5.7二进制包进行多实例安装
一、需求
在一台服务器上安装mysql5.7,并且部署两个实例:3306用于本机主库,3307用于其他MYSQL服务器的从库
二、下载mysql二进制包
[root@push-- src]# mkdir /usr/local/src/mysql-5.7.-linux-glibc2.
[root@push-- src]# cd /usr/local/src/mysql-5.7.-linux-glibc2.
[root@push-- mysql-5.7.-linux-glibc2.]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
三、解压、添加环境变量
[root@push-- mysql-5.7.-linux-glibc2.]# tar -zxvf mysql-5.7.-linux-glibc2.-x86_64.tar.gz
mv mysql-5.7.-linux-glibc2.-x86_64 /usr/local/mysql-5.7.26
[root@push-5-222 /]# vim /etc/profile
PATH=$PATH:/usr/local/mysql-5.7.26/bin
root@push-5-222 /]# source /etc/profile
四、配置3306和3307各自对应的目录
数据目录: /home/mysql-5.7.26/data/3306 /home/mysql-5.7.26/data/330X
日志目录:/home/mysql-5.7.26/log/3306 /home/mysql-5.7.26/log/330X
socket:/var/lib/mysql/330X/mysql.sock
pid-file:/var/run/mysqld/330X/mysqld.pid
log-error:/home/mysql-5.7.26/log/330X/mysqld.log
[root@push-- home]# mkdir -p /home/mysql-5.7./data/
[root@push-- mysql-5.7.]# mkdir -p /home/mysql-5.7./data/
[root@push-- mysql-5.7.]# mkdir -p /var/lib/mysql/
[root@push-- mysql-5.7.]# mkdir -p /var/lib/mysql/
[root@push-- mysql-5.7.]# mkdir -p /var/run/mysqld/
[root@push-- mysql-5.7.]# mkdir -p /var/run/mysqld/
[root@push-- mysql-5.7.]# mkdir -p /home/mysql-5.7./log/
[root@push-- mysql-5.7.]# mkdir -p /home/mysql-5.7./log/
五、将对应的目录授权给mysql用户
[root@push-- mysql-5.7.]# chown -R mysql:mysql /home/mysql-5.7./
[root@push-- /]# chown -R mysql:mysql /var/lib/mysql
[root@push-- /]# chown -R mysql:mysql /var/run/mysqld
六、编辑my-330x配置文件
[root@push-- /]# mkdir /etc/mysql
[root@push-- /]# chown -R mysql:mysql /etc/mysql/
[root@push-- /]# vim /etc/mysql/my-.cnf [mysqld]
#innodb_buffer_pool_size = 128M
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
user=mysql
port=
datadir=/home/mysql-5.7./data/
socket=/var/lib/mysql//mysql.sock
server_id=
#log-bin=master-
#binlog_format=row
#skip-grant-tables
symbolic-links=
pid-file=/var/run/mysqld//mysqld.pid
log-error=/home/mysql-5.7./log//mysqld.log [mysqld_safe]
log-error=/home/mysql-5.7./log//mysqld.log
[root@push-- /]# vim /etc/mysql/my-.cnf [mysqld]
# innodb_buffer_pool_size = 128M
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
user=mysql
port=
datadir=/home/mysql-5.7./data/
socket=/var/lib/mysql//mysql.sock
server_id=
symbolic-links=
pid-file=/var/run/mysqld//mysqld.pid
log-error=/home/mysql-5.7./log//mysqld.log [mysqld_safe]
log-error=/home/mysql-5.7./log//mysqld.log
七、初始化3306和3307数据库
[root@push-- /]# mysqld --defaults-file=/etc/mysql/my-.cnf --initialize --basedir=/usr/local/mysql-5.7./ --datadir=/home/mysql-5.7./data/
[root@push-- /]#
没有报错,查看数据目录是否有系统数据文件
[root@push-- /]# ll /home/mysql-5.7./data/
总用量
-rw-r----- mysql mysql 5月 : auto.cnf
-rw-r----- mysql mysql 5月 : ib_buffer_pool
-rw-r----- mysql mysql 5月 : ibdata1
-rw-r----- mysql mysql 5月 : ib_logfile0
-rw-r----- mysql mysql 5月 : ib_logfile1
drwxr-x--- mysql mysql 5月 : mysql
drwxr-x--- mysql mysql 5月 : performance_schema
drwxr-x--- mysql mysql 5月 : sys
再查看日志文件查找生成的随机root密码,用于第一次登陆数据库使用
[root@push-- /]# cat /home/mysql-5.7./log//mysqld.log |grep password
--27T00::.406309Z [Note] A temporary password is generated for root@localhost: -QOhO4-KccHl
此时,数据库初始化完成了,3307也是同样的操作
[root@push-- /]# mysqld --defaults-file=/etc/mysql/my-.cnf --initialize --basedir=/usr/local/mysql-5.7./ --datadir=/home/mysql-5.7./data/
[root@push-- /]# ll /home/mysql-5.7./data/
总用量
-rw-r----- mysql mysql 5月 : auto.cnf
-rw-r----- mysql mysql 5月 : ib_buffer_pool
-rw-r----- mysql mysql 5月 : ibdata1
-rw-r----- mysql mysql 5月 : ib_logfile0
-rw-r----- mysql mysql 5月 : ib_logfile1
drwxr-x--- mysql mysql 5月 : mysql
drwxr-x--- mysql mysql 5月 : performance_schema
drwxr-x--- mysql mysql 5月 : sys
[root@push-- /]# cat /home/mysql-5.7./log//mysqld.log |grep password
--27T00::.147398Z [Note] A temporary password is generated for root@localhost: <,XBJ?ksp4ZQ
八、分别启动3306和3307数据库
[root@push-- /]# mysqld_safe --defaults-file=/etc/mysql/my-.cnf&
[]
[root@push-- /]# --27T00::.964704Z mysqld_safe Logging to '/home/mysql-5.7.26/log/3306/mysqld.log'.
--27T00::.031905Z mysqld_safe Starting mysqld daemon with databases from /home/mysql-5.7./data/
查看是否有mysqld进程
[root@push-- /]# ps -ef|grep mysqld
root : pts/ :: /bin/sh /usr/local/mysql-5.7./bin/mysqld_safe --defaults-file=/etc/mysql/my-.cnf
mysql : pts/ :: /usr/local/mysql-5.7./bin/mysqld --defaults-file=/etc/mysql/my-.cnf --basedir=/usr/local/mysql-5.7. --datadir=/home/mysql-5.7./data/ --plugin-dir=/usr/local/mysql-5.7./lib/plugin --user=mysql --log-error=/home/mysql-5.7./log//mysqld.log --pid-file=/var/run/mysqld//mysqld.pid --socket=/var/lib/mysql//mysql.sock --port=
root : pts/ :: grep --color=auto mysqld
[root@push-- /]# mysqld_safe --defaults-file=/etc/mysql/my-.cnf&
[]
[root@push-- /]# --27T00::.035649Z mysqld_safe Logging to '/home/mysql-5.7.26/log/3307/mysqld.log'.
--27T00::.095446Z mysqld_safe Starting mysqld daemon with databases from /home/mysql-5.7./data/
^C
[root@push-- /]# ps -ef|grep mysqld
root : pts/ :: /bin/sh /usr/local/mysql-5.7./bin/mysqld_safe --defaults-file=/etc/mysql/my-.cnf
mysql : pts/ :: /usr/local/mysql-5.7./bin/mysqld --defaults-file=/etc/mysql/my-.cnf --basedir=/usr/local/mysql-5.7. --datadir=/home/mysql-5.7./data/ --plugin-dir=/usr/local/mysql-5.7./lib/plugin --user=mysql --log-error=/home/mysql-5.7./log//mysqld.log --pid-file=/var/run/mysqld//mysqld.pid --socket=/var/lib/mysql//mysql.sock --port=
root : pts/ :: /bin/sh /usr/local/mysql-5.7./bin/mysqld_safe --defaults-file=/etc/mysql/my-.cnf
mysql : pts/ :: /usr/local/mysql-5.7./bin/mysqld --defaults-file=/etc/mysql/my-.cnf --basedir=/usr/local/mysql-5.7. --datadir=/home/mysql-5.7./data/ --plugin-dir=/usr/local/mysql-5.7./lib/plugin --user=mysql --log-error=/home/mysql-5.7./log//mysqld.log --pid-file=/var/run/mysqld//mysqld.pid --socket=/var/lib/mysql//mysql.sock --port=
root : pts/ :: grep --color=auto mysqld
此时可以看到3306和3307两个mysqld_safe进程都启动了
八、分别登录3306和3307数据库修改密码
[root@push-- /]# mysql -uroot -p -S /var/lib/mysql//mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. Copyright (c) , , 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>
mysql> alter user 'root'@'localhost' identified by 'xxxxxxxxxxxx';
Query OK, rows affected (0.00 sec) mysql> flush privileges;
Query OK, rows affected (0.00 sec) mysql>
注意,这里一定要使用 -S 方式来连接mysql,修改3307数据库密码
[root@push-- /]# mysql -uroot -p -S /var/lib/mysql//mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. Copyright (c) , , 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> alter user 'root'@'localhost' identified by 'xxxxxxxxx';
Query OK, rows affected (0.00 sec) mysql> flush privileges;
Query OK, rows affected (0.00 sec) mysql>
退出,并重新用新密码登录。
九、设置远程访问权限
[root@push-- /]# mysql -uroot -p -S /var/lib/mysql//mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. MySQL Community Server (GPL) Copyright (c) , , 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;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> update user set host='%' where user='root';
Query OK, row affected (0.00 sec)
Rows matched: Changed: Warnings: mysql> flush privileges;
Query OK, rows affected (0.00 sec) mysql>
,然后通过其他机器客户端连接3306成功。


3307也是同样操作
[root@push-- /]# mysql -uroot -p -S /var/lib/mysql//mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. MySQL Community Server (GPL) Copyright (c) , , 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;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> update user set host='%' where user='root';
Query OK, row affected (0.00 sec)
Rows matched: Changed: Warnings: mysql> flush privileges;
Query OK, rows affected (0.00 sec) mysql>
此时,双实例安装成功。
十、多实例的启动和停止
停止3306实例: mysqladmin -uroot -p -S /var/lib/mysql/3307/mysql.sock shutdown
启动3306实例: mysqld_safe --defaults-file=/etc/mysql/my-3306.cnf &
连接3306实例:mysql -uroot -p -S /var/lib/mysql/3306/mysql.sock
mysql5.7二进制包进行多实例安装的更多相关文章
- MYSQL5.7二进制包的安装
mysql5.7 二进制包安装1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_6 ...
- MYSQL5.5二进制包的安装
二进制1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.5.55-linux2.6-i686.tar.gz2. 解压 tar xx ...
- MYSQL5.6二进制包的安装
二进制1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz2. 解 ...
- MYSQL-5.5二进制包安装
groupadd mysql 添加用户组 useradd mysql -s /sbin/nologin -g mysql -M 添加用户 mv mysql-5.5.54-linux2.6-x86_6 ...
- mysql5.7 二进制包安装
1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz 2. 解 ...
- centos mysql5.7 二进制包安装
此种方式安装非常简单 cd /usr/local 下载安装包wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux- ...
- Linux环境下安装mysql5.6(二进制包不是rpm格式)
一.准备: 1.CentOS release 6.8 2.mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz 3.Linux下MySQL5.6与MySQL5.7安装方法 ...
- Mysql5.6二进制包安装方法
1.Download MySQL Community Server 访问mysql官方网站转到下载页https://dev.mysql.com/downloads/mysql/5.6.html#dow ...
- mysql5.6的二进制包安装
author: headsen chen data :2018-06-08 16:21:43 1. 创建存放软件文件夹 # cd / #mkdir a 2.下载MySQL5.6二进制包 cd a w ...
随机推荐
- Socket上自定义协议总结
TCP只是一个可靠传输的通信管道,上层协议要你自己定的,通俗来说就是发送方和接收方的约定 自定义协议的核心有两个:1. 控制码2. 流程控制 用Socket进行通信,发送的数据包一定是有结构的,类似于 ...
- table 隔列换色
$("table tr").find("td:eq(1),td:eq(2),td:eq(4)").css("background-color" ...
- nfs服务安装部署测试
nfs:网络文件系统作用:某个文件或目录共享,使其它用户可以通过网络访问此共享目录或文件.***特别注意共享的目录权限1.使用nfs需要先安装 yum install -y nfs-utils rpc ...
- Web09_MySQL多表&JDBC
使用JDBC发送insert语句完成单表[添加]操作 使用JDBC发送update语句完成单表[更新]操作 使用JDBC发送delete语句完成单表[删除]操作 使用JDBC发送select语句完成单 ...
- Spring 中如何自动创建代理(spring中的三种自动代理创建器)
Spring 提供了自动代理机制,可以让容器自动生成代理,从而把开发人员从繁琐的配置中解脱出来 . 具体是使用 BeanPostProcessor 来实现这项功能. 这三种自动代理创建器 为:Bean ...
- 6.3.2巴特沃斯(butterworth)低通滤波器
在本程序中,共有六个自定义函数,分别是: 1. myMagnitude(Mat & complexImg,Mat & magnitudeImage),在该函数中封装了Opencv中的 ...
- 容易忽略的javascript知识点的总结
/** 对代码行进行折行 **/您可以在文本字符串中使用反斜杠对代码行进行换行.下面的例子会正确地显示:document.write("Hello \World!"); 不过,您不 ...
- jquery实现分页效果
通过jq实现分页的原理如下:将所有条数加载到页面中,根据每页放特定条数(例如 5 条)获取jquery对象索引,使部分条数显示,其他条数隐藏. 前提:引入jquery.js 代码 <!DOCTY ...
- noi.ac-CSP模拟Day5T2 灯
算是一道思维题吧,没有什么算法在里面. 之前想的是,能走的话就尽量走远,走过去开灯然后再回去关灯,然后再走,每一段路要走3次. 然而,“能走的话就尽量走远”只是yy的一个贪心,没有任何依据.假设在中间 ...
- 【VS开发】ActiveX开发注意事项
[VS开发]ActiveX开发注意事项 标签:[VS开发] 注意:必须在工程的app文件的InitInstance()中加入如下代码,否则动态创建控件不会成功: AfxEnableControlCon ...