MySql Database Backup & Restore

The MySql data files are located in
/var/lib/mysql

but instead of just trying to copy these directly you should use the MySql utilities to backup and restore your database

Quick Backup
#
cat dblist | while read -r db
do
 echo $db
 mysqldump --add-drop-table --allow-keywords --quote-names $db > $db.sql
done


Quick Restore
#
cat dblist | while read -r db
do
 echo $db
 mysql  -e "DROP DATABASE IF EXISTS \`$db\`"
 mysql  -e "CREATE DATABASE IF NOT EXISTS \`$db\`"
 mysql  $db < $db.sql
done


See also
MySqlDump and MySqlRestore


REFERRERS
MySqlAdministration

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki