cat-right

MySQLdump...

Before you can learn how to use mysqldump, you must be aware of what it stands for. It is a command interface that users can employ for moving data. The following example shows you how to move a MySQL database to web hosting.

Step 1

Open a terminal program. Make sure the computer allows you to access the MySQL database at the command line.

Step 2

Enter the following command to make a backup of the database. Replace username, host and database with your own information.

mysqldump –opt -u username -p -h host database> dbdump.sql

Hit the Enter key. Provide the password if required. The time it takes to dump will vary depending on the database size. When it is done, the “dbdump.sql” file will be in the working folder.

Step 3

Make an empty database on the web hosted server. You will have to use the mysqladmin command here. You have the option of using the old database name or giving it a new one. Enter the following command:

mysqladmin -u username -p -h host create database

Just like when you learned how to use mysqldump, replace the username, host and database with the appropriate information. Hit the Enter key. Provide the password when it is required.

Step 4

Now you can create and populate the database. You can provide the “dbdump.sql” as the script for “mysql”. This action will result in the script creating the database. The data will be added. Type the following:

mysql -u username -p -h host database < dbdump.sql

Replace the username, host and database with the information on the database. Press the Enter key. The time it takes for the script to run its course will depend on the database. A large database will mean it will take several minutes. A smaller database will require less time.

When to Use the Command

The MySQL relational database is utilized in numerous Internet content management systems, blogs and picture galleries. It is also used in many applications.

The time may come when it becomes necessary to relocate the MySQL database. During these occasions, the instructions provided above will come in handy. Because it will automatically rebuild the database, the transition will become easier and less of a problem.

In other words, by learning how to use mysqldump, you can move the files on your website to another host with ease. Using the command is also recommended for those who want to alter some parts of their database.