Lap4 Mysql Replication
Lap4 Mysql Replication
= 127.0.0.1
We want to replicate the database exampledb, so we put the following lines into /etc/mysql/my.cnf vo th [mysqld] log-bin = /var/lib/mysql/mysql-bin.log binlog-do-db=exampledb server-id=1
Then we restart MySQL: /etc/init.d/mysql restart Then we log into the MySQL database as root and create a user with replication privileges: mysql -u root -p Enter password:
+---------------+----------+-------------+------------------+ | File | Position | Binlog_do_db | Binlog_ignore_db | +---------------+----------+-------------+------------------+ | mysql-bin.006 | 183 | exampledb | | +---------------+----------+-------------+----------
Write down this information, we will need it later on the slave! 2 Configure The Slave
Now we have to tell MySQL on the slave that it is the slave, that the master is 192.168.0.100, and that the master database to watch is exampledb. Therefore we add the following lines to /etc/mysql/my.cnf: vo th [mysqld]
Kim tra status replication : mysql> show slave status \G ; Hng dn ly password mysql khi khng nh password : /usr/bin/mysqld_safe--user=mysql--skip-grant-tables --skip-networking & mysql UPDATE mysql user SET Password=PASSWORD('12345') WHERE User='root';