mariadb

MySQL and MariaDB are the most popular database systems that use the SQL language. It’s important to take a quick backup before making some changes in your existing data. And no system or application is fully fail-proof, so any unexpected thing can happen at a time when you least expect it. So, for protecting your MySQL database, backup is a must.

First , let’s begin by checking the database name by typing this query:

mysql -u root -p

Then type:

Show databases;

Now quit from MySQL:

quit

Mysqldump command is used for taking the MySQL backup. The syntax of taking the backup is as follows:

mysqldump -u root -p your_db_name > /backup/your_db_name.sql

After the command is run, enter your MySQL root password.

Sometimes we need to take the entire database backup. At that time, you can use the command:

mysqldump -u root -p –all-databases > /backup/all_db.sql

Some time we need to take a single table backup, at that time we can use the command given below:

mysql -u root -p database name table name > databasename_tablename.sql

For example, if we need to take the backup of the author table in testdb database, then we need to type the following command:

mysqldump -u root -p testdb accounts >testdb_accounts.sql

In order to restore the database backup, we have to use the command:

mysql -u root -p testdb < /backup/testdb.sql

Enjoy!

-Adv-

LEAVE A REPLY

Please enter your comment!
Please enter your name here