天天看點

mySQL 增量備份方案

1.在 /etc/my.cnf 下面設定開啟bin-log

         編輯

         vim /etc/my.cnf

         [mysqld]

         binlog_format       = MIXED                 //binlog日志格式

         log_bin             =目錄/mysql-bin.log    //binlog日志名

         expire_logs_days    = 7                //binlog過期清理時間

         #max_binlog_size    100m                    //binlog每個日志檔案大小 最大值和預設是1個G

         binlog-do-db=game     #需要備份的資料庫名,如果備份多個資料庫,重複設定這個選項即可

         binlog-do-db=platform #

         #binlog-ignore-db=不需要備份的資料庫,如果備份多個資料庫,重複設定這個選項即可

mySQL 增量備份方案

2.建立遠端登陸資料庫帳号

         grant all privileges on game.* to 'jack'@'192.168.10.56' identified by 'admin'

         grant all privileges on platform.* to 'jack'@'192.168.10.56' identified by 'admin'

3.将伺服器上的資料,導入一份進遠端伺服器中

         mysqldump -ujack -padmin -h192.168.10.38 > 備份資料庫位址(/home/mysql/db/mysql.sql);

4.寫Linux 計劃任務:

         vim /etc/crontab

在底部加入

         0 3 * * * root sh /home/wwwroot/sh/mysqlbackup.sh #每天3點以root帳号的權限執行目錄下的sh

重新開機服務

         /etc/init.d/crond restart

---------------------------------------------------

如果遇到了問題,請檢視一下

select super_priv,user from user where host='192.168.10.39';

update user set super_priv='Y' where user='game1';