Build MySQL mirror database under Linux

Source: Internet
Author: User
Tags log modify mysql mysql version create database linux
mysql| Data | Database MySQL version: 4.1 5, starting from the library, the master-slave database data synchronization

The following are the referenced contents:
/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,

The following are the referenced contents:
Mysql>create database sampdb;

Mysql>create table New (name char (), phone char (20));

Mysql>insert into new (' ABC, ' 0532555555 ');

open from Library, view:
The following are the referenced contents:
/opt/mysql/bin/mysql-u root-p

Mysql>show database;

Mysql

Sampdb

Test

Mysql>use sampdb;

Mysql>show tables;

New

Indicates that the master-slave database was created successfully.

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.

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:

The following are the referenced contents:
[Mysqld]

server-id=2

master-host=192.168.0.205

Master-user=slave

master-password=123456




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.