The following is the GNU All-permissive License as recommended in https://www.gnu.org/licenses/license-recommendations.en.html
Copyright (C) 2024 Free Software Foundation sysadmin@fsf.org
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.
Contributions are welcome. See https://savannah.gnu.org/maintenance/fsf/.
restore flat db dump file
These instructions come from rwp, and apply to some of the vms that he works on, such as Savannah.
To restore a full database dump:
zcat < mysql.dump.20170415084708 | mysql -uROOTUSER -pROOTPASS
To restore a specific database:
Use sed to filter out other databases.
time zcat mysql.dump.20170415084708 |
sed -n '/^CREATE DATABASE.*`foo_database`/,/^CREATE DATABASE/p' |
mysql -uSOMEUSER -pSOMEPASS foo_database
To restore a specific table from a specific database:
Use sed to filter out other databases.
Then use sed to filter out other tables. In my case here the name
of the table is foo_table and so I am looking for that specific table.
time zcat mysql.dump.20170415084708 |
sed -n '/^CREATE DATABASE.*`foo_database`/,/^CREATE DATABASE/p' |
sed -n '/^DROP TABLE.* `foo_table`/,/^UNLOCK TABLES/p' |
mysql -uSOMEUSER -pSOMEPASS foo_database