快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

多实例安装mysql5.7的示例分析

这篇文章主要介绍多实例安装MySQL 5.7的示例分析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

创新互联专业为企业提供大箐山网站建设、大箐山做网站、大箐山网站设计、大箐山网站制作等企业网站建设、网页设计与制作、大箐山企业网站模板建站服务,10余年大箐山做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

datadir:

mkdir -p /home/data/3306

mkdir -p /home/data/3307

mkdir -p /home/data/3308

chown -R mysql /home/data/

cd /opt/mysql

初始化mysql

./bin/mysqld --initialize --datadir=/home/data/3306 --user=mysql

./bin/mysqld --initialize --datadir=/home/data/3307 --user=mysql

./bin/mysqld --initialize --datadir=/home/data/3308 --user=mysql

启动mysql

bin/mysqld_safe --defaults-file=/opt/mysql/3306.cnf --user=mysql &

bin/mysqld_safe --defaults-file=/opt/mysql/3307.cnf --user=mysql &

bin/mysqld_safe --defaults-file=/opt/mysql/3308.cnf --user=mysql &

修改密码

注意:执行bin/mysqld --initialize的时候,日志会输出初始化的密码

关键字 A temporary password is generated for root@localhost: 

mysql> set password = password('rootroot');

mysql> flush privileges;

配置环境变量

vim  /etc/profile 添加 

export PATH=$PATH:/opt/mysql/bin

刷新环境变量

source /etc/profile

配置别名

vim /root/.bashrc

```

alias mysql3306='mysql -uroot -prootroot -P3306 --socket=/home/data/3306/mysql.sock'

alias start_mysql_3306='/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/3306.cnf --user=mysql &'

alias stop_mysql_3306='mysqladmin shutdown -uroot -p"rootroot" --socket=/home/data/3306/mysql.sock'

alias mysql3307='mysql -uroot -prootroot -P3307 --socket=/home/data/3307/mysql.sock'

alias start_mysql_3307='/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/3307.cnf --user=mysql &'

alias stop_mysql_3307='mysqladmin shutdown -uroot -p"rootroot" --socket=/home/data/3307/mysql.sock'

alias mysql3308='mysql -uroot -prootroot -P3308 --socket=/home/data/3308/mysql.sock'

alias start_mysql_3308='/opt/mysql/bin/mysqld_safe --defaults-file=/opt/mysql/3308.cnf --user=mysql &'

alias stop_mysql_3308='mysqladmin shutdown -uroot -p"rootroot" --socket=/home/data/3308/mysql.sock'

```

建立主从

change master to 

MASTER_HOST="192.168.64.52",

MASTER_USER="root",

MASTER_PASSWORD="rootroot",

MASTER_PORT=3306, 

MASTER_CONNECT_RETRY=10, 

MASTER_AUTO_POSITION = 1;

编辑 /opt/mysql/3306.cnf

```

[mysql]

prompt = "\u@master \R:\m:\s [\d]> "

[client]

port  = 3306

socket = /data/mysql/data/mysql.sock

[mysqld]

datadir=/home/data/3306

socket=/home/data/3306/mysql.sock

skip-name-resolve

symbolic-links=0

log_bin = binlog

binlog_format= ROW

slow_query_log = 1

slow_query_log_file = slow.log

log-error = error.log

innodb_buffer_pool_size =512MB

innodb_buffer_pool_instances = 1

[mysqld_safe]

log-error=/home/data/3306/mysqld-err.log

```

编辑 /opt/mysql/3307.cnf

```

[mysql]

prompt = "\u@3307\R:\m:\s [\d]> "

[client]

port  =3307

socket = /data/mysql/data/mysql.sock

[mysqld]

datadir=/home/data/3307

socket=/home/data/3307/mysql.sock

skip-name-resolve

symbolic-links=0

log_bin = binlog

binlog_format= ROW

slow_query_log = 1

slow_query_log_file = slow.log

log-error = error.log

innodb_buffer_pool_size =512MB

innodb_buffer_pool_instances = 1

```

编辑 /opt/mysql/3308.cnf

```

[mysql]

prompt = "\u@3308\R:\m:\s [\d]> "

[client]

port  =3308

socket = /data/mysql/data/mysql.sock

[mysqld]

datadir=/home/data/3308

socket=/home/data/3308/mysql.sock

skip-name-resolve

symbolic-links=0

log_bin = binlog

binlog_format= ROW

slow_query_log = 1

slow_query_log_file = slow.log

log-error = error.log

innodb_buffer_pool_size =512MB

innodb_buffer_pool_instances = 1

```

以上是“多实例安装mysql 5.7的示例分析”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!


文章题目:多实例安装mysql5.7的示例分析
分享路径:http://6mz.cn/article/pgjhcj.html

其他资讯