mysql 主从配置(windows xp 开二个 mysql 测试)
2009-09-24 00:00:00 来源:WEB开发网环境 :
个人 pc xp 一台 ;
使用 :
官方下载: mysql-noinstall-5.1.36-win32.zip
1. 解压 成2个 (文件夹)
mysql-5.1.36-win32_1 (主)
mysql-5.1.36-win32_2 (从)
2. 配置文件修改
主服务器配置修改
>mysql-5.1.36-win32_1/my-small.ini 修改名称为 my.ini
>修改刚才 my.ini 文件的
[client]
port = 3307
[mysqld]
server-id = 1
port = 3307
binlog-do-db =test
binlog-ignore-db=backup
log-bin=mysql-bin
>启动 mysql-5.1.36-win32_1/bin/mysqld.exe --defaults-file=..youpath .my-small.ini
>使用 主 mysql -u root 创建同步角色
GRANT REPLICATION SLAVE,RELOAD,SUPER ON *.*
TO backup@'127.0.0.1'
IDENTIFIED BY '1234';
>并且运行
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 106 | test | backup |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
从服务器配置:
>mysql-5.1.36-win32_2/my-small.ini 修改名称为 my.ini
>修改刚才 my.ini 文件的
[client]
#password = your_password
port = 3308
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
server-id = 2
master-host = 127.0.0.1
master-user = backup
master-password = 1234
master-port = 3307
port = 3308
>启动 mysql-5.1.36-win32_2/bin/mysqld.exe ( 我这会有个警告,没事 )
>参考 主服务器运行的 show master status; 数据
slave stop;
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=106;
slave start;
然后 :
在主mysql服务器
use test
create table tt (ii int);
然后在从mysql服务器
use test
show tables;
mysql> show tables ;
+----------------+
| Tables_in_test |
+----------------+
| tt |
+----------------+
1 row in set (0.00 sec)
赞助商链接