一、需求

在一台服务器上安装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二进制包进行多实例安装的更多相关文章

  1. MYSQL5.7二进制包的安装

    mysql5.7 二进制包安装1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_6 ...

  2. MYSQL5.5二进制包的安装

    二进制1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.5.55-linux2.6-i686.tar.gz2. 解压 tar xx ...

  3. MYSQL5.6二进制包的安装

    二进制1. 下载包 wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz2. 解 ...

  4. MYSQL-5.5二进制包安装

    groupadd mysql 添加用户组 useradd mysql -s /sbin/nologin -g mysql -M  添加用户 mv mysql-5.5.54-linux2.6-x86_6 ...

  5. mysql5.7 二进制包安装

    1. 下载包 wget   http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz 2. 解 ...

  6. centos mysql5.7 二进制包安装

    此种方式安装非常简单 cd /usr/local 下载安装包wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux- ...

  7. 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安装方法 ...

  8. Mysql5.6二进制包安装方法

    1.Download MySQL Community Server 访问mysql官方网站转到下载页https://dev.mysql.com/downloads/mysql/5.6.html#dow ...

  9. mysql5.6的二进制包安装

    author: headsen chen data :2018-06-08  16:21:43 1. 创建存放软件文件夹 # cd / #mkdir a 2.下载MySQL5.6二进制包 cd a w ...

随机推荐

  1. 半硬化树脂PP的型号

    1080是PP半固化胶片的型号(perperg),还有7628,2116,2113,2112,1506等等型号,每种型号不一样代表其PP内部的玻纤布不一样,比如7628的玻纤布相对较粗.数值较小则玻纤 ...

  2. Cannot find terminfo entry for 'linux'.

    解决方案: 1. 查看 /usr/share/terminfo 目录下的内容,该目录的内容表示该主机支持哪些终端类型. 2. 通过修改系统变量TERM为vt100. 执行 export TERM=vt ...

  3. CSS - 设置 select 元素的样式

    注意:option 外面有个框,这个框不同浏览器生成的还不一样,给这个框设置样式的方法也没有找到(有说法是这是浏览器创建的 shadow dom 没法设置).所以要想完全控制还是用列表进行模拟比较好. ...

  4. nagios客户端安装监控

    1.在客户端机器上安装epel扩展源 yum install -y epel-release2.yum安装nagios及依赖包软件 yum install -y nagios-plugins nagi ...

  5. I/O检测介绍

    I/O性能监测可总结如下:* 任何时间出现CPU等待IO,说明磁盘超载.* 计算出你的磁盘可维持的IOPS值.* 判定你的应用是属于随机磁盘访问型还是有序型.* 通过对比等待时间和服务时间即可判断磁盘 ...

  6. centos7 安装mongodb4.0笔记

    1,添加yum源 vim /etc/yum.repos.d/mongodb-4.0.repo 2,把下面内容加入,并:wq [mongodb-org-4.0] name=MongoDB Reposit ...

  7. Unity2D RPG游戏开发日志

    一.游戏构建设计 场景设计:地面的每一层用unity的TiledMap来设计,首先第一层为地面层,也就是地形的大部分区域的图块:第二层为覆盖层,如图中蓝色线圈起来的柱子的上半部分,由于玩家可以在柱子背 ...

  8. cocos2dx基础篇(1) Cocos2D-X项目创建

    已经入行工作半年多时间了,以前都是把这些东西记录在有道云上面的,现在抽出些时间把以前的笔记腾过来. 具体的环境配置就不用说了,因为现在已经是2018年,只需要下载对应版本解压后就能使用,不用再像多年前 ...

  9. vs资源视图加载失败

    原因:引用了未知的资源,通过打开时报的错可以定位然后修改

  10. Qt - 基于HTTP的网络编程

    HTTP(超文本传输协议 Hyper Text Transfer Protocol) 基于TCP/IP通信协议,属于应用层协议. 使用情况: HTTP是无连接(无连接的含义是限制每次连接只处理一个请求 ...