欢迎投稿

今日深度:

win10上安装mysql8 并配置主从复制,

win10上安装mysql8 并配置主从复制,


最近在学习springboot,想整理一篇博客,关于springboot整合mybatis并配置主从数据库的,但是电脑win10系统上并没有配置mysql主从数据库。所以花了几天的时间终于整好了。在这里记录一下。

首先是关于在win10上安装两个mysql8的步骤,我找到了一篇博客,按照上面的步骤,是可以配置成功的。

https://blog.csdn.net/imHanweihu/article/details/89404165

这里有几个问题需要注意的:

    1.删除mysql  mysqld remove [服务名]  如:mysqld remove mysql1 

     2.如果出现下述错误,可以删除data文件夹:

D:\developeTool\mysqlnew\mysql-8.0.17-winx64\bin>mysqld --initialize --user=mysql --console
2020-03-20T15:31:23.847864Z 0 [System] [MY-013169] [Server] D:\developeTool\mysqlnew\mysql-8.0.17-winx64\bin\mysqld.exe (mysqld 8.0.17) initializing of server in progress as process 15208
2020-03-20T15:31:23.848961Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2020-03-20T15:31:23.849652Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2020-03-20T15:31:23.849671Z 0 [ERROR] [MY-013236] [Server] The designated data directory D:\developeTool\mysqlnew\mysql-8.0.17-winx64\Data\ is unusable. You can remove all files that the server added to it.
2020-03-20T15:31:23.864040Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-03-20T15:31:23.864162Z 0 [System] [MY-010910] [Server] D:\developeTool\mysqlnew\mysql-8.0.17-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL.

  3.对于下列错误:以管理员身份运行cmd,执行sc delete mysql即可  

The service already exists!
The current server installed: D:\developeTool\mysql\mysql-8.0.17-winx64\bin\mysqld MySQL

   4.对于启动mysql2 使用net start mysql2命令启动,然后使用mysql -u root -p 启动,并输入mysql2的初始密码

   按照上门的步骤,应该就能安装成功了。

-----------------------------------------------------------------分界线------------------------------------------------------------------------------------------------

接下来是关于配置主从复制的步骤:

    我这里是使用的navicat配置的。

1.连接上主库,按F6打开命令行。

       1.在主库上创建一个用户用来复制。依次执行下面命令

create user 'repl'@'%' identified by 'repl';
grant replication slave,replication client on *.* to 'repl'@'%';
flush privileges;

    2.执行 show master status 命令,

  

  2.连接从库,按F6打开命令行。

     1.设置从库监听主库的命令行;

change master to master_host='192.168.*.*',master_port=3306,master_user='repl',master_password='repl',master_log_file='mysql-bin.000006',master_log_pos=0

 master_host 主库ip
  master_port 主库端口
  master_user 上面新建的用户
  master_password 上面新建用户的密码
  master_log_file 主库命令行中的file值
  master_log_pos 主库命令行中的position值

  2.在从库最好执行下下面的代码,跳过slave上的1个错误;(我就在这里卡了好久,终于解决了这个bug)

set global sql_slave_skip_counter=1

  3.启动slave

start slave;

  4.验证;show slave status;红框范围内的两个都要为yes,即设置成功了。

    接下来可以在master上创建一个表。在slave上对应的库下执行查询,能查询到表。到这儿在win10上配置mysql8的主从复制就完成了。

    在linux上安装mysql并配置主从,可以查看我的另一篇博客: https://www.cnblogs.com/pluto-charon/p/11925360.html 

www.htsjk.Com true http://www.htsjk.com/Mysql/42543.html NewsArticle win10上安装mysql8 并配置主从复制, 最近在学习springboot,想整理一篇博客,关于springboot整合mybatis并配置主从数据库的,但是电脑win10系统上并没有配置mysql主从数据库。所以花了几天的...
相关文章
    暂无相关文章
评论暂时关闭