filmov
tv
MySQL : mysqldump database backup

Показать описание
MySQL mysqldump
The mysqldump client is a backup program was written by Igor Romanenko.
It can be used to dump a database or a collection of databases for backup .
The dump typically contains SQL statements to create the table, populate it, or both.
However, mysqldump can also be used to generate files in CSV, other delimited text, or XML format.
Create MYSQL backup user
*************************
MYSQL
GRANT SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'mysqlbackup'@'localhost';
GRANT LOCK TABLES ON *.* TO 'mysqlbackup'@'localhost';
Passwordless login using a string
*********************************
$
mysql_config_editor print --all
mysql_config_editor set --login-path=emultiskills_MYSQL_mysqlbackup --host=localhost --user=mysqlbackup --password
-- It prompts for the password.
mysql --login-path=emultiskills_MYSQL_mysqlbackup
MYSQL BACKUP SHELL SCRIPT
*************************
#!/bin/bash
export DUMP_PATH=/mysql/backup/
DATE=`date +%d%b%Y`
mysqldump --login-path=emultiskills_MYSQL_mysqlbackup --all-databases " angled bracket" ${DUMP_PATH}/linux2_all_MySQLdump_${DATE}.sql
RC1=$?
if [ $RC1 -ne 0 ];then
echo "Backup unsuccessful"
else
echo "Backup successful"
echo "Deleting the below old backup files"
find ${DUMP_PATH} -name "linux2_all_MySQLdump_*" -type f -mtime +3 -exec ls {} \;
if [ $? = 0 ];then
find ${DUMP_PATH} -name "linux2_all_MySQLdump_*" -type f -mtime +3 -exec rm {} \;
fi
fi
**********************Clean up ********************************
mysql -u root -p
drop user 'mysqlbackup'@'localhost';
mysql_config_editor print --all
mysql_config_editor remove --login-path=emultiskills_MYSQL_mysqlbackup
mysql_config_editor print --all
The mysqldump client is a backup program was written by Igor Romanenko.
It can be used to dump a database or a collection of databases for backup .
The dump typically contains SQL statements to create the table, populate it, or both.
However, mysqldump can also be used to generate files in CSV, other delimited text, or XML format.
Create MYSQL backup user
*************************
MYSQL
GRANT SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'mysqlbackup'@'localhost';
GRANT LOCK TABLES ON *.* TO 'mysqlbackup'@'localhost';
Passwordless login using a string
*********************************
$
mysql_config_editor print --all
mysql_config_editor set --login-path=emultiskills_MYSQL_mysqlbackup --host=localhost --user=mysqlbackup --password
-- It prompts for the password.
mysql --login-path=emultiskills_MYSQL_mysqlbackup
MYSQL BACKUP SHELL SCRIPT
*************************
#!/bin/bash
export DUMP_PATH=/mysql/backup/
DATE=`date +%d%b%Y`
mysqldump --login-path=emultiskills_MYSQL_mysqlbackup --all-databases " angled bracket" ${DUMP_PATH}/linux2_all_MySQLdump_${DATE}.sql
RC1=$?
if [ $RC1 -ne 0 ];then
echo "Backup unsuccessful"
else
echo "Backup successful"
echo "Deleting the below old backup files"
find ${DUMP_PATH} -name "linux2_all_MySQLdump_*" -type f -mtime +3 -exec ls {} \;
if [ $? = 0 ];then
find ${DUMP_PATH} -name "linux2_all_MySQLdump_*" -type f -mtime +3 -exec rm {} \;
fi
fi
**********************Clean up ********************************
mysql -u root -p
drop user 'mysqlbackup'@'localhost';
mysql_config_editor print --all
mysql_config_editor remove --login-path=emultiskills_MYSQL_mysqlbackup
mysql_config_editor print --all