Importing all MySQL databases

I mysqldump --all-databases

at night as a backup. But when importing this dump into a clean install, I obviously ran into several issues.

  • I obviously can't (and don't want to) overwrite the new schema-info.
  • All my users and permission settings will be lost unless I overwrite the database mysql

    .

What is standard practice in this situation? Parse the information.schema file from .sql before downloading? And whether to overwrite the database mysql

or not?

+1


source to share


2 answers


you will have no problem with information schema



http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html mysqldump does not dump the INFORMATION_SCHEMA database. If you name this database explicitly on the command line, mysqldump silently ignores it.

+2


source


Try a bash script to exclude the database.



 for DB in $(echo "show databases" | mysql -u <username> -p'<password>' | grep -v Database  grep -v <some_db_to_exclude>)
do
    mysqldump -u <username> -p'<password>' ${DB}
done

      

0


source







All Articles