{"id":24469,"date":"2022-02-02T14:36:38","date_gmt":"2022-02-02T14:36:38","guid":{"rendered":"https:\/\/1-grid.com\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/"},"modified":"2025-05-27T09:41:52","modified_gmt":"2025-05-27T09:41:52","slug":"vps-how-to-restore-a-mysql-dump-via-command-line","status":"publish","type":"ht_kb","link":"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/","title":{"rendered":"VPS: How to restore a MySQL dump via command line ?"},"content":{"rendered":"<blockquote><p><span style=\"color: #000000;\">This article provides you with information on how to restore a MySQL dump via Linux command line.<\/span><\/p><\/blockquote>\n<p><span style=\"color: #000000;\">Prerequisites:<\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/1-grid.com\/vps-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">VPS Sserver<\/a><\/li>\n<li><span style=\"color: #000000;\">A Linux operating system<\/span><\/li>\n<li><span style=\"color: #000000;\">MySQL installed<\/span><\/li>\n<li><span style=\"color: #000000;\">An existing database<\/span><\/li>\n<li><span style=\"color: #000000;\">Mysqldump utility ( included with your MySQL software)<\/span><\/li>\n<\/ul>\n<div>\n<h2><span style=\"color: #000000;\"><strong>How to back Up from the Command-Line with mysqldump?<\/strong><\/span><\/h2>\n<\/div>\n<div>\n<p><span style=\"color: #000000;\">The\u00a0mysqldump client utility can dump a database including the SQL\u00a0statements required to rebuild the database.<\/span><\/p>\n<p><span style=\"color: #000000;\">By default, the dump file includes the SQL commands to restore the tables and data.<\/span><\/p>\n<p><span style=\"color: #000000;\">To backup your MySQL database, the general syntax is:<\/span><\/p>\n<pre>sudo mysqldump -u [user] -p [database_name] &gt; [filename].sql<\/pre>\n<ul>\n<li><span style=\"color: #000000;\">Replace [user] with your username and password (if needed).<\/span><\/li>\n<li><span style=\"color: #000000;\">The [database_name] is the path and filename of the database.<\/span><\/li>\n<li><span style=\"color: #000000;\">The\u00a0&gt;\u00a0command specifies the output.<\/span><\/li>\n<li><span style=\"color: #000000;\">[filename] is the path and filename you want to save the dump file as.<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">Other examples:<\/span><\/p>\n<p><span style=\"color: #000000;\">To back up of an entire Database Management System:<\/span><\/p>\n<pre>mysqldump --all-databases --single-transaction --quick --lock-tables=false &gt; full-backup-$(date +%F).sql -u root -p<\/pre>\n<p><span style=\"color: #000000;\">To include more than one database in the backup dump file:<\/span><\/p>\n<pre>sudo mysqldump -u [user] -p [database_1] [database_2] [database_etc] &gt; [filename].sql<\/pre>\n<\/div>\n<div>\n<h2><span style=\"color: #000000;\"><strong>How to Restore MySQL with mysqldump?<\/strong><\/span><\/h2>\n<\/div>\n<div>\n<h3><span style=\"color: #000000;\"><strong>Step 1 &#8211; \u00a0<\/strong> Create New Database<\/span><\/h3>\n<\/div>\n<div>\n<p><span style=\"color: #000000;\">On the system that hosts the database, use MySQL to create a new database.<\/span><\/p>\n<pre>mysql -u root -p\u00a0\nCREATE DATABASE new_database;<\/pre>\n<p><span style=\"color: #000000;\">Make sure you\u2019ve named it the same as the database you lost. This creates the foundation file that mysqldump will import the data into. Since the dump file has the commands to rebuild the database, you only need to create the empty database.<\/span><\/p>\n<\/div>\n<div>\n<h3><span style=\"color: #000000;\"><strong>Step 2 &#8211;<\/strong> Restore MySQL Dump<\/span><\/h3>\n<\/div>\n<div>\n<p><span style=\"color: #000000;\">To restore a MySQL backup, enter:<\/span><\/p>\n<pre>mysql -u [user] -p [database_name] &lt; [filename].sql<\/pre>\n<p><span style=\"color: #000000;\">Make sure to include\u00a0[database_name] and\u00a0[filename] in the path.<\/span><\/p>\n<p><span style=\"color: #000000;\">It\u2019s likely that on the host machine,\u00a0[database_name] can be in a root directory, so you may not need to add the path. Make sure that you specify the exact path for the dump file you\u2019re restoring, including server name (if needed).<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article provides you with information on how to restore a MySQL dump via Linux command line. Prerequisites: VPS Sserver A Linux operating system MySQL installed An existing database Mysqldump utility ( included with your MySQL software) How to back Up from the Command-Line with mysqldump? The\u00a0mysqldump client utility can&#8230;<\/p>\n","protected":false},"author":21,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"ht-kb-category":[1197],"ht-kb-tag":[205,326,480,569,662,855,1094,1101,1106],"class_list":["post-24469","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-vps","ht_kb_tag-command","ht_kb_tag-dump","ht_kb_tag-how-to","ht_kb_tag-line","ht_kb_tag-mysql","ht_kb_tag-restore","ht_kb_tag-via","ht_kb_tag-vps","ht_kb_tag-web-hosting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Vps: How To Restore A Mysql Dump Via Command Line? | 1-grid<\/title>\n<meta name=\"description\" content=\"Restore MySQL Dump via Command Line effectively and confidently with our detailed guide: 1-grid Knowledge Base\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Vps: How To Restore A Mysql Dump Via Command Line? | 1-grid\" \/>\n<meta property=\"og:description\" content=\"Restore MySQL Dump via Command Line effectively and confidently with our detailed guide: 1-grid Knowledge Base\" \/>\n<meta property=\"og:url\" content=\"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/\" \/>\n<meta property=\"og:site_name\" content=\"1-grid Knowledge Base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/1grid.co.za\/\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-27T09:41:52+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@1grid_hosting\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/\",\"name\":\"Vps: How To Restore A Mysql Dump Via Command Line? | 1-grid\",\"isPartOf\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#website\"},\"datePublished\":\"2022-02-02T14:36:38+00:00\",\"dateModified\":\"2025-05-27T09:41:52+00:00\",\"description\":\"Restore MySQL Dump via Command Line effectively and confidently with our detailed guide: 1-grid Knowledge Base\",\"breadcrumb\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/1grid.co.za\/knowledge\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VPS: How to restore a MySQL dump via command line ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#website\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/\",\"name\":\"1-Grid Domain Hosting Knowledge Base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/1grid.co.za\/knowledge\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#organization\",\"name\":\"1-Grid Domain Hosting Knowledge Base\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg\",\"contentUrl\":\"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg\",\"width\":100,\"height\":100,\"caption\":\"1-Grid Domain Hosting Knowledge Base\"},\"image\":{\"@id\":\"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/1grid.co.za\/\",\"https:\/\/twitter.com\/1grid_hosting\",\"https:\/\/www.instagram.com\/1grid_hosting\/\",\"https:\/\/za.linkedin.com\/company\/1-grid\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Vps: How To Restore A Mysql Dump Via Command Line? | 1-grid","description":"Restore MySQL Dump via Command Line effectively and confidently with our detailed guide: 1-grid Knowledge Base","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:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/","og_locale":"en_US","og_type":"article","og_title":"Vps: How To Restore A Mysql Dump Via Command Line? | 1-grid","og_description":"Restore MySQL Dump via Command Line effectively and confidently with our detailed guide: 1-grid Knowledge Base","og_url":"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/","og_site_name":"1-grid Knowledge Base","article_publisher":"https:\/\/www.facebook.com\/1grid.co.za\/","article_modified_time":"2025-05-27T09:41:52+00:00","twitter_card":"summary_large_image","twitter_site":"@1grid_hosting","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/","url":"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/","name":"Vps: How To Restore A Mysql Dump Via Command Line? | 1-grid","isPartOf":{"@id":"https:\/\/1grid.co.za\/knowledge\/#website"},"datePublished":"2022-02-02T14:36:38+00:00","dateModified":"2025-05-27T09:41:52+00:00","description":"Restore MySQL Dump via Command Line effectively and confidently with our detailed guide: 1-grid Knowledge Base","breadcrumb":{"@id":"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/1grid.co.za\/knowledge\/vps-how-to-restore-a-mysql-dump-via-command-line\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/1grid.co.za\/knowledge\/"},{"@type":"ListItem","position":2,"name":"VPS: How to restore a MySQL dump via command line ?"}]},{"@type":"WebSite","@id":"https:\/\/1grid.co.za\/knowledge\/#website","url":"https:\/\/1grid.co.za\/knowledge\/","name":"1-Grid Domain Hosting Knowledge Base","description":"","publisher":{"@id":"https:\/\/1grid.co.za\/knowledge\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/1grid.co.za\/knowledge\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/1grid.co.za\/knowledge\/#organization","name":"1-Grid Domain Hosting Knowledge Base","url":"https:\/\/1grid.co.za\/knowledge\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/","url":"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg","contentUrl":"https:\/\/1grid.co.za\/knowledge\/wp-content\/uploads\/2023\/01\/1-grid-logo-color.svg","width":100,"height":100,"caption":"1-Grid Domain Hosting Knowledge Base"},"image":{"@id":"https:\/\/1grid.co.za\/knowledge\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/1grid.co.za\/","https:\/\/twitter.com\/1grid_hosting","https:\/\/www.instagram.com\/1grid_hosting\/","https:\/\/za.linkedin.com\/company\/1-grid"]}]}},"_links":{"self":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/24469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/comments?post=24469"}],"version-history":[{"count":3,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/24469\/revisions"}],"predecessor-version":[{"id":33259,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb\/24469\/revisions\/33259"}],"wp:attachment":[{"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/media?parent=24469"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb-category?post=24469"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/1grid.co.za\/knowledge\/wp-json\/wp\/v2\/ht-kb-tag?post=24469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}