首页 > 学院 > 开发设计 > 正文

Windows下MySQL多实例/主从复制/重置密码/WordPress主从配置

2019-11-08 20:45:02
字体:
来源:转载
供稿:网友

Windows创建MySQL多实例

安装MYSQL运行mysql-installer-community-5.7.16.0.msi选择组件MySQL Server 5.7.16 – X64

复制实例

将C:/PRogramData/MySQL/MySQL拷贝为MYSQL1和MYSQL2文件夹修改各文件夹中的my.inimy.ini创建服务mysqld -install mysql1 --defaults-file="C:/ProgramData/MySQL/MySQL1/my.ini"mysqld -install mysql2 --defaults-file="C:/ProgramData/MySQL/MySQL2/my.ini"启动服务net start mysql1net start mysql2MySQL Master/Slave配置主从机上使用相同的usr账户和密码并同时赋予REPLICATION SLAVE和REPLICATION CLIENT权限,前者用于数据同步,后者用于监视SLAVE同步状况:               GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO usr@'192.168.0.%' IDENTIFIED BY 'pwd';   2. 将主服务器数据dump/export,然后在从数据中import/restore。如果使用Workbench的export和import功能注意import的时候存储过程和方法因为不包含任何Scheme操作或被忽略,需要手动执行对应sql文件以进行创建。      然后执行同步:mysqlreplicate --master=usr:pwd@192.168.0.1 --slave=user:pwd@192.168.0.2 --rpl-user=usr:pwd

错误及解决办法

ERROR: The slave’s server_id is the same as the master.将主服务器的my.ini配置中Server_id=1修改Server_id=2ERROR: Master must have binary logging turned on.

在从服务器的my.ini配置中启用二进制日志

# Binary Logging.# log-binlog-bin=mysql-binERROR: The slave’s UUID is the same as the master.

在从服务器数据文件夹Data中修改auto.cnf文件中的server-uuid

[auto]server-uuid=b1a3dd23-edc7-11e6-81b8-480fcf275eaf

MySQL忘记root密码

在my.ini配置文件[mysqld]下增加skip-grant-tables并重启MySQL服务执行如下SQLuse mysql;update MySQL.user set authentication_string=passWord('rootpassword') where user='root' ;将my.ini配置文件中的skip-grant-tables注释或删除并重启MySQL服务

Wordpress数据库主从复制配置

下载Wordpress插件HyperDB并解压缩将db.php拷贝到wp-content文件夹中将db-config.php拷贝到根目录与wp-config.php同级文件夹修改db-config.php将只读数据库配置项host对应的值由DB_HOST修改为DB_SLAVE在wp-config.php中增加配置define('DB_SLAVE', ‘salve db ip address');
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表