MySQL Version: 4.1
Environment Introduction: Main Library 192.168.0.205 from library 192.168.0.206
1, the main library to create/ETC/MY.CNF, modify [mysqld] inside the key value increase
Server-id=1
Log-bin=binlog_name
2, the main library to increase the user to read the main library log from the library.
Grant replication Slave,reload,super on *.* to ' slave ' @ ' 192.168.0.206 ' identified by ' 123456 '
3, from the library to connect the main library for testing.
/opt/mysql/bin/mysql-u slave-p-H 192.168.0.205
4, stop from the library, modify from the library/etc/my.cnf, add options:
[mysqld]
server-id=2
master-host=192.168.0.205
master-user=slave
master-password=123456
5, starting from the library, the master-slave database data synchronization
/opt/mysql/share/mysql/mysql start
/opt/mysql/bin/mysql-u root-p
Mysql>load data from Master;
Description: This step can also be used to pour into the database or direct catalogue test.
6, the test:
The main library creates the table,
mysql>create database sampdb;
mysql>create table new (name char(20),phone char(20));
mysql>insert into new (’abc,’0532555555’);
Open from library, view:
/opt/mysql/bin/mysql -u root -p
mysql>show database;
mysql
sampdb
test
mysql>use sampdb;
mysql>show tables;
new
说明主从数据库创建成功。
7, master-slave Database related commands:
Slave stop; Slave start; Start stopping from the database.
show slave status\g; Shows which primary database binary log is being read from the library
Purge master logs to ' binlog.000004 '; This command is very careful to delete the binary log files that are not used by the primary database. If you mistakenly delete, then there is no way to automatically update from the library.
Change Master to modify the parameter usage from the server.