Mysql Master-Slave configuration

Source: Internet
Author: User
Tags dsn yii

1. Modify the MySQL configuration file for the master server
Vi/etc/my.cnf
[mysqld] Log //  server-id=1//

Pagoda-installed MySQL By default this is the one you don't have to change.

Then create an accessible user to access from the server

GRANT all on * * to [email protected]'%'123456'
View current master server information MySQL

2. Start configuration from server

vim/etc/my.cnf[mysqld] Server-id=2

Then log in to MySQL

Mysql>change Master to master_host='114.215.186.197', master_user= ' User '
Master_password= ' 123456 ', master_log_file=' file ' of the master server, ----- This is mysql-bin.000005.

Master_log_pos= position of the primary server; -----me, this is 577.

Turn on Sync
View synchronization Status

Two are all yes is successful, if there is a connecting that is the wrong password, or password did not take

Plus the configuration of Yii read-write separation

'DB'= [            'class'='yii\db\connection',            //Configuring the primary server            'DSN'='Mysql:host=118.25.108.136;dbname=yii_book',            'username'='User',            'Password'='123456',            'CharSet'='UTF8',            //Configure the slave server            'Slaveconfig'= [                'username'='User',                'Password'='123456',                'attributes'= [                    //Use a smaller connection timeoutPdo::attr_timeout =Ten,                ],                'CharSet'='UTF8',            ],            //Configure the From server group            'Slaves'= [                ['DSN'='Mysql:host=116.196.83.132;dbname=yii_book'],            ],        ],

Mysql Master-Slave configuration

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.