1. The operation of MySQL database, before changing the configuration file, add and modify data, the full library script to export the backup and physical file export work, in case the operation error. If the operation goes wrong, you can quickly roll back the database to its original state.
2. Set the complex root user password, and make the correct authorization, and flush privileges; to refresh permissions. If the root password is missing, you can modify the root user's mysql password. But the database will require a reboot.
3. Select OK MySQL The Client Connection tool, such as Navicat or SQL Yog .
4. Set up the correct backup policy, as well as the backup script, as follows:
[Email protected]]# more mysqlfull.sh
#!/bin/sh
# Name:mysqlFullBackup.sh
# Ps:mysql DataBase full Backup.
# Use mysqldump--help get more detail.
Scriptsdir= ' pwd '
Mysqldir=/var/lib/mysql
User=root
Userpwd=xxxxxx
Databackupdir=/usr/local/sdc/backup/mysqlbackup
emailfile= $dataBackupDir/email.txt
[Email protected]
logfile= $dataBackupDir/mysqlbackup.log
Date= ' Date-i '
echo "" > $eMailFile
echo $ (date + "%y-%m-%d%h:%m:%s") >> $eMailFile
CD $dataBackupDir
Dumpfile=mysql_$date.sql
Gzdumpfile=mysql_$date.sql.tar.gz
#mysqldump-u$user-p$userpwd--opt--default-character-set=utf8--extended-insert=false--triggers-r-- Hex-blob--all-databases--flush-logs--delete-master-logs--delete-master-logs-x > $dumpFile
Mysqldump-u$user-p$userpwd--all-databases > $dumpFile
#if [[$? = = 0]]
If ["$?" = "0"]
Then
Tar czf $GZDumpFile $dumpFile >> $eMailFile 2>&1
echo "BackupFileName: $GZDumpFile" >> $eMailFile
echo "DataBase Backup success!" >> $eMailFile
Rm-f $dumpFile
# Delete daily backup files.
# CD $dataBackupDir/daily
# rm-f *
# Delete old backup files (mtime>2).
# $scriptsDir/rmbackup.sh
Find $dataBackupDir-type f-mtime +33-execrm {} \;
# Move Backup Files to backup Server.
# if ((!$?)); Then
# echo "Move backup Files to backup Server success!" >> $eMailFile
# Else
# echo "Move backup Files to backup Server fail!" >> $eMailFile
# fi
Else
echo "DataBase Backup fail!" >> $emailFile
Fi
echo "--------------------------------------------------------" >> $logFile
Cat $eMailFile >> $logFile
#cat $eMailFile | Mail-s "Mysqlbackup" $eMail
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/B0/wKioL1Ppo5PjszMxAAaXu3084OU213.jpg "title=" MySQL connection condition. jpg "alt=" wkiol1ppo5pjszmxaaaxu3084ou213.jpg "/>
This article is from the "Lin XI" blog, please be sure to keep this source http://lutaoxu.blog.51cto.com/4224602/1538943