Once a database has been created it can be very useful to be able to export the data and then import it on another Slice or server.
This procedure is very simple and can greatly ease any migration of data.
Let's get stuck right in and look at exporting the database.
In this example, we will export the 'mytestdb' database into a file called 'mytestdb.sql':
mysqldump -u root -p mytestdb > mytestdb.sql
Er, that's it.
Once done, the sql file can be copied to a new Slice or server ready to be imported into MySQL.
Importing the data is just as easy but involves two steps.
The first step is to create a blank database ready to receive the data (remember this is on the Slice or server to which the database is going to imported):
mysqladmin -u root -p create mytestdb2
Once done, all that is left is to actually import the data:
mysql -u root -p mytestdb2 < mytestdb.sql
Done. It really is as simple as that.
Although a short article, it really does show the power of using the command line when administering MySQL.
One command to export the database, and then two simple commands to import the data into a new Slice MySQL installation.