I want to export the sql script to recreate a particular database and it’s tables, and then export another script to populate the content of the tables.
I’d then like to be able to run the script on a different MySQL instance and setup the same database structure, and then load the content.
I’m not sure why you think you need two scripts as you can export the schemas and content in a single script. To create this, the easiest solution is to use the mysqldump command line tool that’s bundled with MySQL. This will create a text file that you can use the restore the entire database/specific tables, etc. to their original state.
As a hint, you might want to take special notice of the “–add-drop-table” option as this will prove useful if you ever want to stomp over whatever’s there with the contents of the backup file. (N.B.: This will of course wipe out ALL the “current” data.)
That said, if you want you can simply dump the schema information via the
--no-dataoption. (And use--no-create-infoto simply dump the content.)