The following article describes how to create a MySQL Image Database in linux. We use MySQL (the best combination with PHP: 4.1. The following describes the specific operations in the article.
Environment Introduction: master database 192.168.0.205 slave database 192.168.0.206
1. Create a MySQL Image Database in linux:
Create/etc/my. cnf in the master database and modify the key value in [MySQL (the best 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. Create a MySQL Image Database in linux:
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 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 (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 slave database.
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.
The above content is an introduction to the creation of a MySQL Image Database in linux. I hope you will have some gains.