#!/bin/bash
db_user="root"
db_passwd="123456"
db_host="localhost"
backup_dir="/usr/local/apache2/htdocs/backup"
time="$(date +"%y%m%d%h%m")"
mysql="/usr/local/mysql/bin/mysql"
mysqldump="/usr/local/mysql/bin/mysqldump"
mkdir="/bin/mkdir"
rm="/bin/rm"
mv="/bin/mv"
gzip="/bin/gzip"
test ! -w $backup_dir && echo "error: $backup_dir is un-writeable." && exit 0
test ! -d "$backup_dir/$time" && $mkdir -p "$backup_dir/$time"
all_db="$($mysql -u $db_user -h $db_host -p$db_passwd -bse 'show databases')"
for db in $all_db
do$mysqldump "——default-character-set=gbk" -u $db_user -h $db_host -p$db_passwd $db | $gzip -9 > "$backup_dir/$time/$db.gz"
done
exit 0;
設定定時任務,每天凌晨3點15分執行該指令碼進行資料庫備份
15 3 * * * sh /usr/scripts/mysql_backup.sh
基於rmp在linux環境下安裝mysql
很久沒手動安裝過mysql了現在就在這裡記錄一下一些坑 具體安裝流程可以參考 菜鳥教程 安裝完畢後,mysql安裝目前在 usr bin mysql root izwz9d32g6iuzyahpuwt0tz usr which mysql usr bin mysql配置檔案在 etc my.cnf ...
Linux下利用Docker搭建MYSQL5 7
1 建立mysql配置目錄 建立配置目錄 mkdir p etc mysql conf.d 建立資料和日誌目錄 mkdir pv opt mysql 2 修改my.cnf配置 輸入 sudo vim etc mysql conf.d my.cnf,新增如下內容 mysqld default stor...
基於linux系統下的MYSQL自動備份
db user root db passwd 123456 db host localhost backup dir usr local apache2 htdocs backup time date y m d h m mysql usr local mysql bin mysql mysqldu...