{"id":5120,"date":"2023-05-08T09:28:33","date_gmt":"2023-05-08T09:28:33","guid":{"rendered":"https:\/\/www.webhi.com\/how-to\/?p=5120"},"modified":"2023-05-08T09:28:35","modified_gmt":"2023-05-08T09:28:35","slug":"backup-and-restore-a-mysql-mariadb-database-using-mysqldump","status":"publish","type":"post","link":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/","title":{"rendered":"Back up and restore a MySQL \/ MariaDB database using mysqldump"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/05\/mysqldump_backup_restore_en.jpg\" alt=\"backup and restore a MySQL \/ MariaDB database using mysqldump\" class=\"wp-image-5144\" srcset=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/05\/mysqldump_backup_restore_en.jpg 1200w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/05\/mysqldump_backup_restore_en-300x169.jpg 300w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/05\/mysqldump_backup_restore_en-1024x576.jpg 1024w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/05\/mysqldump_backup_restore_en-768x432.jpg 768w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/05\/mysqldump_backup_restore_en-150x84.jpg 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p>MySQL and MariaDB are two of the most widely used relational database management systems in the world. As with any database, it is important to have a backup of your data in case of any unexpected data loss or corruption. This is where <strong><code>mysqldump<\/code> <\/strong>comes in.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-mysqldump\">What is mysqldump?<\/h2>\n\n\n\n<p><code>mysqldump<\/code> is a command-line tool that allows you to back up and restore your MySQL or MariaDB databases. It is a powerful tool that can be used to create backups of your databases, as well as to export the data to a file or to a remote server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-backup-a-mysql-or-mariadb-database-using-mysqldump\">How to back up a MySQL or MariaDB Database using mysqldump<\/h2>\n\n\n\n<p>Backing up a MySQL or MariaDB database using <code>mysqldump<\/code> is a relatively simple process. To create a backup of your database, you can use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ mysqldump -u [username] -p[password] [database_name] &gt; [backup_file_name].sql<\/code><\/pre>\n\n\n\n<p>This command will create a backup of your database in a file with the name&nbsp;<code>[backup_file_name].sql<\/code>. The&nbsp;<code>[username]<\/code>&nbsp;and&nbsp;<code>[password]<\/code>&nbsp;parameters are used to specify the username and password that will be used to connect to the database. The&nbsp;<code>[database_name]<\/code>&nbsp;parameter is used to specify the name of the database that you want to back up.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-restore-a-mysql-or-mariadb-database-using-mysqldump\">How to Restore a MySQL or MariaDB Database using mysqldump<\/h2>\n\n\n\n<p>Restoring a MySQL or MariaDB database using mysqldump is just as easy as backing it up. To restore a backup of your database, you can use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ mysql -u [username] -p[password] [database_name] &lt; [backup_file_name].sql<\/code><\/pre>\n\n\n\n<p>This command will restore the backup of your database from the file with the name&nbsp;<code>[backup_file_name].sql<\/code>. The&nbsp;<code>[username]<\/code>&nbsp;and&nbsp;<code>[password]<\/code>&nbsp;parameters are used to specify the username and password that will be used to connect to the database. The&nbsp;<code>[database_name]<\/code>&nbsp;parameter is used to specify the name of the database that you want to restore.<\/p>\n\n\n\n<p>Alternatively, you can use the following command to restore a backup of your database and import the data into a new database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ mysql -u [username] -p[password] [database_name] &lt; [backup_file_name].sql [new_database_name].sql<\/code><\/pre>\n\n\n\n<p>This command will restore the backup of your database from the file with the name&nbsp;<code>[backup_file_name].sql<\/code>&nbsp;and import the data into a new database with the name&nbsp;<code>[new_database_name]<\/code>. The&nbsp;<code>[username]<\/code>&nbsp;and&nbsp;<code>[password]<\/code>&nbsp;parameters are used to specify the username and password that will be used to connect to the database. The&nbsp;<code>[database_name]<\/code>&nbsp;parameter is used to specify the name of the database that you want to restore, and the&nbsp;<code>[new_database_name]<\/code>&nbsp;parameter is used to specify the name of the new database that you want to import the data into.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>In conclusion, <code>mysqldump<\/code> is a powerful tool that can be used to backup and restore MySQL and MariaDB databases. Whether you are looking to create a backup of your database, export the data to a file, or restore a backup and import the data into a new database, <code>mysqldump <\/code>is the tool for the job. With its simple syntax and wide range of options, it is easy to use and understand, making it a valuable asset for any MySQL or MariaDB administrator.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL and MariaDB are two of the most widely used relational database management systems in the world. As with any database, it is important to have a backup of your data in case of any unexpected data loss or corruption. This is where mysqldump comes in. What is mysqldump? mysqldump is a command-line tool that ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[57,69],"tags":[],"yoast_head":"\n<title>Back up and restore a MySQL \/ MariaDB database using mysqldump - WebHi Tutorials &amp; Documentations<\/title>\n<meta name=\"description\" content=\"Learn how to backup and restore your MySQL or MariaDB databases using the powerful tool of mysqldump. This article covers the basic syntax and options of mysqldump, making it easy to create backups and restore data in case of unexpected data loss or corruption.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Back up and restore a MySQL \/ MariaDB database using mysqldump - WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"og:description\" content=\"Learn how to backup and restore your MySQL or MariaDB databases using the powerful tool of mysqldump. This article covers the basic syntax and options of mysqldump, making it easy to create backups and restore data in case of unexpected data loss or corruption.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhi.technology\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-08T09:28:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-08T09:28:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/05\/mysqldump_backup_restore_en.jpg\" \/>\n<meta name=\"author\" content=\"webhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:site\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webhi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/\"},\"author\":{\"name\":\"webhi\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\"},\"headline\":\"Back up and restore a MySQL \/ MariaDB database using mysqldump\",\"datePublished\":\"2023-05-08T09:28:33+00:00\",\"dateModified\":\"2023-05-08T09:28:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/\"},\"wordCount\":495,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"articleSection\":[\"Databases\",\"Linux system administration\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/\",\"name\":\"Back up and restore a MySQL \/ MariaDB database using mysqldump - WebHi Tutorials &amp; Documentations\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\"},\"datePublished\":\"2023-05-08T09:28:33+00:00\",\"dateModified\":\"2023-05-08T09:28:35+00:00\",\"description\":\"Learn how to backup and restore your MySQL or MariaDB databases using the powerful tool of mysqldump. This article covers the basic syntax and options of mysqldump, making it easy to create backups and restore data in case of unexpected data loss or corruption.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webhi.com\/how-to\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Back up and restore a MySQL \/ MariaDB database using mysqldump\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"name\":\"WebHi Tutorials &amp; Documentations\",\"description\":\"System administration and knowledge base\",\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\",\"name\":\"WebHi Technology\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"width\":288,\"height\":95,\"caption\":\"WebHi Technology\"},\"image\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webhi.technology\",\"https:\/\/twitter.com\/WebHiTechnology\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\",\"name\":\"webhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743\",\"caption\":\"webhi\"},\"sameAs\":[\"https:\/\/www.webhi.com\/how-to\"],\"url\":\"https:\/\/www.webhi.com\/how-to\/author\/webhi\/\"}]}<\/script>\n","yoast_head_json":{"title":"Back up and restore a MySQL \/ MariaDB database using mysqldump - WebHi Tutorials &amp; Documentations","description":"Learn how to backup and restore your MySQL or MariaDB databases using the powerful tool of mysqldump. This article covers the basic syntax and options of mysqldump, making it easy to create backups and restore data in case of unexpected data loss or corruption.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/","og_locale":"en_US","og_type":"article","og_title":"Back up and restore a MySQL \/ MariaDB database using mysqldump - WebHi Tutorials &amp; Documentations","og_description":"Learn how to backup and restore your MySQL or MariaDB databases using the powerful tool of mysqldump. This article covers the basic syntax and options of mysqldump, making it easy to create backups and restore data in case of unexpected data loss or corruption.","og_url":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/","og_site_name":"WebHi Tutorials &amp; Documentations","article_publisher":"https:\/\/www.facebook.com\/webhi.technology","article_published_time":"2023-05-08T09:28:33+00:00","article_modified_time":"2023-05-08T09:28:35+00:00","og_image":[{"url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/05\/mysqldump_backup_restore_en.jpg"}],"author":"webhi","twitter_card":"summary_large_image","twitter_creator":"@WebHiTechnology","twitter_site":"@WebHiTechnology","twitter_misc":{"Written by":"webhi","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/#article","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/"},"author":{"name":"webhi","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54"},"headline":"Back up and restore a MySQL \/ MariaDB database using mysqldump","datePublished":"2023-05-08T09:28:33+00:00","dateModified":"2023-05-08T09:28:35+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/"},"wordCount":495,"commentCount":0,"publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"articleSection":["Databases","Linux system administration"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/","url":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/","name":"Back up and restore a MySQL \/ MariaDB database using mysqldump - WebHi Tutorials &amp; Documentations","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/#website"},"datePublished":"2023-05-08T09:28:33+00:00","dateModified":"2023-05-08T09:28:35+00:00","description":"Learn how to backup and restore your MySQL or MariaDB databases using the powerful tool of mysqldump. This article covers the basic syntax and options of mysqldump, making it easy to create backups and restore data in case of unexpected data loss or corruption.","breadcrumb":{"@id":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhi.com\/how-to\/backup-and-restore-a-mysql-mariadb-database-using-mysqldump\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhi.com\/how-to\/"},{"@type":"ListItem","position":2,"name":"Back up and restore a MySQL \/ MariaDB database using mysqldump"}]},{"@type":"WebSite","@id":"https:\/\/www.webhi.com\/how-to\/#website","url":"https:\/\/www.webhi.com\/how-to\/","name":"WebHi Tutorials &amp; Documentations","description":"System administration and knowledge base","publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webhi.com\/how-to\/#organization","name":"WebHi Technology","url":"https:\/\/www.webhi.com\/how-to\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","contentUrl":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","width":288,"height":95,"caption":"WebHi Technology"},"image":{"@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhi.technology","https:\/\/twitter.com\/WebHiTechnology"]},{"@type":"Person","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54","name":"webhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/","url":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743","contentUrl":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743","caption":"webhi"},"sameAs":["https:\/\/www.webhi.com\/how-to"],"url":"https:\/\/www.webhi.com\/how-to\/author\/webhi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/5120"}],"collection":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/comments?post=5120"}],"version-history":[{"count":10,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/5120\/revisions"}],"predecessor-version":[{"id":5148,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/5120\/revisions\/5148"}],"wp:attachment":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/media?parent=5120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/categories?post=5120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/tags?post=5120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}