Environment:
Personal PC Windows7 one;
Use:
Official Download: Mysql-noinstall-5.5.11-win32.zip
1. Unzip into 2 (folder)
Mysql_master (Master)
Mysql_slave (from)
2. Configuration file Modification
Master server Configuration Modification
Mysql_master/my-huge.ini Modify the name to My.ini
Modify the My.ini file that was just
[Client]
Port = 3306
[Mysqld]
Server-id = 1
Port = 3306
Binlog-do-db =test #同步test, if it is closed, the other libraries are synchronized except those that are not allowed.
Binlog-ignore-db=backup Sync Backup Library, the following ibid.
Binlog-ignore-db=mysql
Binlog-ignore-db=information_schema
Log-bin=mysql-bin
Start Mysql-5.1.36-win32_1/bin/mysqld.exe
Now back up the data on master;
Mysql>flush TABLES with READ LOCK;
Create a sync role using primary mysql-u root
Mysql>grant REPLICATION slave,reload,super On * * to [e-mail protected] ' 127.0.0.1 ' identified by ' 123456 ';;
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)
The file,position here will be used from the library.
From the server configuration:
Mysql-5.1.36-win32_2/my-huge.ini Modify the name to My.ini
Modify the My.ini file that was just
[Client]
#password = Your_password
Port = 3307
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 = 123456
Master-port = 3306
Port = 3307
Start Mysql-5.1.36-win32_2/bin/mysqld.exe
The situation I was experiencing was not successfully started, check the error log
Found [ERROR] d:/mysql_slave/bin/mysqld:unknown variable ' master-host=127.0.0.1 '
Then comment out the following four lines
Master-host = 127.0.0.1
Master-user = Backup
Master-password = 1234
Master-port = 3307
Execute the following command again.
Slave stop;
Change Master to master_host= ' 127.0.0.1 ', master_user= ' backup ', master_password= ' 123456 ', master_log_file= ' Mysql-bin.000001 ', master_log_pos=106;
Slave start;
You can see the situation from the library by show slave status. But there's too much information. For easy viewing, you can use the following command
show slave status \g;
Check the above Slave_io_running:yes and Slave_sql_running:yes 2 are Yes to prove that master-slave synchronization is normal, if any one shows no, it proves that there is a problem with synchronization. Can view the database log file, which basically shows the error, according to the error step by step troubleshooting, basically can be resolved.
Unlock the main library table;
UNLOCK TABLES;
Test
On the primary MySQL server
Use test
CREATE TABLE TT (ii int);
And then in from the MySQL server
Use test
Show tables;
Mysql> Show tables;
+----------------+
| Tables_in_test |
+----------------+
| tt |
+----------------+
1 row in Set (0.00 sec)