Create a MySQL Image Database in linux

Source: Internet
Author: User

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 ].

 
 
  1. server-id=1   
  2. log-bin=binlog_name   

2. Add users to the master database to read logs from the master database.

 
 
  1. 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.

 
 
  1. /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:

 
 
  1. [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,

 
 
  1. 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:

 
 
  1. /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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.