The following articles teach you how to correctly create a MySQL Image Database in linux. in MySQL (the best combination with PHP) Version 4.1, the environment is the master database 192.168.0.205 from the database 192.168.0.206 to operate on it.
1. Create/etc/my. cnf in the master database and modify the key value in [MySQL (optimal combination with PHP) d ].
- server-id=1
- log-bin=binlog_name
2. Add users to the master database to read logs from the master database.
- grant replication slave,reload,super on *.* to ’slave’@’192.168.0.206’ identified by ’123456’
3. Connect the slave database to the master database for testing.
/Opt/MySQL (the best combination with PHP)/bin/MySQL (the best combination with PHP)-u slave-p-h 192.168.0.205
4. Stop the slave database, modify the slave database/etc/my. cnf, and add the following options:
[MySQL (best combination with PHP) d] server-id = 2 master-host = 192.168.0.205 master-user = slave master-password = 123456
5. Start slave database for master-slave Database Data Synchronization
/Opt/MySQL (the best combination with PHP)/share/MySQL (the best combination with PHP) start
/Opt/MySQL (the best combination with PHP)/bin/MySQL (the best combination with PHP)-u root-p
MySQL (the best combination with PHP)> load data from master;
Note: You can use the MySQL image database to import the data or use the directory to test the data in this step.
6. perform the test:
Create a table in the master database,
MySQL (the best combination with PHP)> create database sampdb; MySQL (the best combination with PHP)> create table new (name char (20 ), phone char (20); MySQL (the best combination with PHP)> insert into new ('abc, '123 ');
Open the slave database and check:
/Opt/MySQL (the best combination with PHP)/bin/MySQL (the best combination with PHP)-u root-p MySQL (the best combination with PHP)> show database; MySQL (the best combination with PHP) sampdb test MySQL (the best combination with PHP)> use sampdb; MySQL (the best combination with PHP)> show tables; new
The master database is successfully created.
7. commands related to the Master/Slave database:
Slave stop; slave start; start to stop the image database from MySQL.
Show slave status \ G; displays the binary log of the primary database that is being read from the database.
Purge master logs to 'binlog. 100'; this command is very careful to delete binary log files that are useless to the master database. If it is deleted by mistake, the slave database cannot be automatically updated.
Change master; modify the parameter usage on the server.