Open In App

How to Generate Database Dump of MySQL Database in Linux?

Last Updated : 30 Jun, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

We will learn how to Backup and Restore your MySQL Database with Mysqldump query in LINUX.  We had always a need that if the production database is corrupted somehow, we should be able to recover it, for recovering we should always keep a backup of the database at particular instances. So, data rollback can be done.

First, we will create a Database in our system. We will need LAMPP and APACHE Software for this purpose.

Step 1: Create a database using the below command:

CREATE DATABASE geeksforgeeks;

Step 2: Use the database using the below command:

USE geeksforgeeks;

Step 3: Create a table in this database as shown below:

CREATE TABLE employeeData(ID INT(10),
            Name VARCHAR(255),
            Designation VARCHAR(255),
            Address VARCHAR(255),
            Branch VARCHAR(255)
            );

Step 4: Describe this table to see if it is correctly created or not:

DESC employeeData;

Employee Data Table is successfully created

Step 5: Insert some data in this table.

INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (1,"Devesh Pratap Singh","Software Engineer","Uttar Pradesh, India", "Noida");
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (2,"Megha Arele","Web Developer","Uttar Pradesh, India", "Noida");
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (3,"Aditya Srivastava","Research Analyst","Uttar Pradesh, India", "Noida");
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (4,"Tanishka Sharma","Jr. Architect","Uttar Pradesh, India", "Noida");
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (3,"Divyanshi Upadhyay","Jr. Architect","Uttar Pradesh, India", "Noida");

Step 6: Dump the data for backup for restoring purposes with the below command:

mysqldump -u root -p geeksforgeeks > ~/Desktop/backup_db.sql

After running this command you will get the dumped database on your desktop.

Output File


Similar Reads

dump command in Linux with examples
dump command in Linux is used for backup the filesystem to some storage device. It backs up the complete file system and not the individual files. In other words, it backups the required files to tape, disk or any other storage device for safe storage. The dump command in Linux works only with ext2/ext3 filesystem and not with others like FAT and R
4 min read
S3Scanner - Scan For Open S3 Buckets And Dump
S3 stores data as objects within resources called "buckets". There can be some critical data dumped into the bucket. Permissions need to be assigned as per the seriousness of the bucket. In some cases, the bucket can be opened or it can be available for public access. So to identify this bucket for the particular domain we can use the S3Scanner too
2 min read
Checking MySQL Database Size in Linux
Mysql is the most popular open-source database among developers. It is developed and managed by Oracle Corporation and initially released on 23 May 1995. It is compatible with each operating system, Like(Linux, Windows, and macOS) which is major support for web-based applications. In this article, we are going to see how to get the size of a databa
2 min read
MySQL | Common MySQL Queries
MySQL server is a open-source relational database management system which is a major support for web based applications. Databases and related tables are the main component of many websites and applications as the data is stored and exchanged over the web. Even all social networking websites mainly Facebook, Twitter, and Google depends on MySQL dat
9 min read
PHP | MySQL Database Introduction
What is MySQL? MySQL is an open-source relational database management system (RDBMS). It is the most popular database system used with PHP. MySQL is developed, distributed, and supported by Oracle Corporation. The data in a MySQL database are stored in tables which consists of columns and rows.MySQL is a database system that runs on a server.MySQL
4 min read
PHP | MySQL ( Creating Database )
What is a database? Database is a collection of inter-related data which helps in efficient retrieval, insertion and deletion of data from database and organizes the data in the form of tables, views, schemas, reports etc. For Example, university database organizes the data about students, faculty, and admin staff etc. which helps in efficient retr
3 min read
PHP | Inserting into MySQL database
Prerequisites : MySQL introduction, Creating MySQL database INSERT INTO statement is used to insert new rows in a database table. Let's see the syntax how to insert into table, considering database already exists. SYNTAX : INSERT INTO TABLE_NAME (column1, column2, column3, ... columnN) VALUES (value1, value2, value3, ...valueN); Here, column1, colu
4 min read
MySQL | DATABASE() and CURRENT_USER() Functions
DATABASE() Function The DATABASE() Function in MySQL returns the name of the default or current database. The string or name returned by DATABASE() function uses the utf8 character set. If there is no default database,the Database function returns NULL. In the older versions than MySQL 4.1.1,The Database function used to return an empty string, if
2 min read
MySQL | Database Files
Whenever MySQL database installation is done, all the database related data and metadata are stored in one folder. This is the actual database schema with some values in it. Let us explore more about it. The file extensions are as follows: .frm – This is the extension of file which contains the schema or definition of the table..myd – This is the e
5 min read
Database Backup from MySQL
Here, The database creating now a day is very important for daily work. The database creates from the MySQL that can be transferred from one system to another and also make it secure from the destroy. Sometimes the system gets corrupted by some faults, so the created database is clear. So there is an option to create a backup of a database from the
2 min read
Article Tags :