I am retiring a couple Linux servers, a web server and a database one.. I made a full database backup using the mysqldump command. Now I wanted to restore one, specific, database from this file on this Windows environment. This particular migration is of a network / WordPress Mu server. My MySQL server is installed on a Windows server, running IIS, and PHP.
Syntax:
open the Windows command prompt, navigate to your MySQL server installation, in my case this is at C:\MySQL\, then navigate to the bin folder where the exe mysql file resides.
mysql -u root -p --one-database destdbname < alldatabases.sql
Substitute dbname with the database name you want to restore, and alldatabases.sql with the name of your full DB backup.
If you would rather just extract the database dump of the single database from the --all-databases dump file, you can do this with sed using this command:
sed -n '/^-- Current Database: `dbname`/,/^-- Current Database: `/p' alldatabases.sql > output.sql
dbname is replaced with the database name of the database to extract, and alldatabases.sql is the name of your dump file. The result will be saved into the file output.sql.
Example from my environment:
C:\MySQL\bin>mysql -u root -p --one-database wpmu < C:\Users\administrator.A
D\Desktop\all_databases.sql
Enter password: *********
No comments:
Post a Comment