{"id":1050,"date":"2021-03-17T10:40:38","date_gmt":"2021-03-17T08:40:38","guid":{"rendered":"https:\/\/www.scalahosting.com\/kb\/?p=1050"},"modified":"2023-06-20T15:33:01","modified_gmt":"2023-06-20T12:33:01","slug":"how-to-import-and-export-a-mysql-database","status":"publish","type":"post","link":"https:\/\/www.scalahosting.com\/kb\/how-to-import-and-export-a-mysql-database\/","title":{"rendered":"How to Import and Export a MySQL Database"},"content":{"rendered":"\n<p><span style=\"font-weight: 400;\">This article provides <\/span><b>a quick guide on how to import and export a MySQL database<\/b><span style=\"font-weight: 400;\">. We\u2019ll be guiding you through all you need to know to run these simple tasks.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">You can <a href=\"https:\/\/www.scalahosting.com\/kb\/how-to-create-a-database-in-mysql\/\" target=\"_blank\" rel=\"noreferrer noopener\">create MySQL databases<\/a> and set up MySQL users via the <strong>MySQL databases<\/strong> tool available in SPanel&#8217;s User Interface.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"408\" height=\"165\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h30_43.png\" alt=\"How to Import and Export a MySQL Database\" class=\"wp-image-1051\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h30_43.png 408w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h30_43-300x121.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><span style=\"font-weight: 400;\">And here\u2019s <\/span><b>how to import and export data<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>How to Import a MySQL Database<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">There would probably be an occasion where you\u2019d want to import a MySQL database into your server. You can do that through either of these <\/span><b>two ways<\/b><span style=\"font-weight: 400;\"> \u2014 <\/span><i><span style=\"font-weight: 400;\">phpMyAdmin or using the command line<\/span><\/i><span style=\"font-weight: 400;\">. Use this guide to get started.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"font-weight: 400;\">Method 1: Using PhpMyAdmin<\/span><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">PhpMyAdmin is a <\/span><b>free database management platform&nbsp;<\/b>that allows you to control your databases via<span style=\"font-weight: 400;\"><b> a browser-based graphical <\/b><\/span><b>interface.<\/b><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Here\u2019s how.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Log in to your <\/span><a href=\"https:\/\/www.scalahosting.com\/kb\/getting-started-with-spanel\/\"><span style=\"font-weight: 400;\">SPanel&#8217;s User Interface<\/span><\/a>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"453\" height=\"456\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2022\/01\/40.png\" alt=\"How to Import and Export a MySQL Database, Method 1: Using PhpMyAdmin\" class=\"wp-image-2898\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2022\/01\/40.png 453w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2022\/01\/40-298x300.png 298w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2022\/01\/40-150x150.png 150w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><span style=\"font-weight: 400;\">Open phpMyAdmin <\/span><b>from the Databases section on the homepage<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"463\" height=\"162\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_04.png\" alt=\"How to Import and Export a MySQL Database, Method 1: Using PhpMyAdmin 2\" class=\"wp-image-1053\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_04.png 463w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_04-300x105.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><span style=\"font-weight: 400;\">SPanel will redirect you to the phpMyAdmin web interface. Click <\/span><b>Import<\/b><span style=\"font-weight: 400;\"> on the top menu bar.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"597\" height=\"252\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_11.png\" alt=\"How to Import and Export a MySQL Database, Method 1: Using PhpMyAdmin 3\" class=\"wp-image-1054\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_11.png 597w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_11-300x127.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><b>Select the file<\/b><span style=\"font-weight: 400;\"> you want to import.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Before that, <\/span><b>compress the file<\/b><span style=\"font-weight: 400;\"> as gzip, bzip2 or zip, or leave it uncompressed. <\/span><b>Save it on your computer<\/b><span style=\"font-weight: 400;\"> using this nomenclature \u2014 <\/span><i><span style=\"font-weight: 400;\">.[format].[compression]<\/span><\/i><span style=\"font-weight: 400;\"> \u2014 example, .sql.zip<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"540\" height=\"188\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_21.png\" alt=\"How to Import and Export a MySQL Database, Method 1: Using PhpMyAdmin 4\" class=\"wp-image-1055\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_21.png 540w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_21-300x104.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><b>Select the file format<\/b><span style=\"font-weight: 400;\"> and click on the <\/span><b>Go<\/b><span style=\"font-weight: 400;\"> button to begin the import.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"464\" height=\"298\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_29.png\" alt=\"How to Import and Export a MySQL Database, Method 1: Using PhpMyAdmin 5\" class=\"wp-image-1056\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_29.png 464w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_29-300x193.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><span style=\"font-weight: 400;\">The process will start running, and you\u2019ll see the imported database after completion.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Method 2: Using Command Line<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Importing a MySQL database through the command line <\/span><b>requires a <\/b><a href=\"https:\/\/www.scalahosting.com\/kb\/access-server-ssh\/\"><b>secure shell (SSH) access<\/b><\/a><span style=\"font-weight: 400;\">. SSH <\/span><b>allows you to remotely log in<\/b><span style=\"font-weight: 400;\"> to your hosting account to perform tasks through text commands.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">It enables webmasters to perform tasks <\/span><b>as if they\u2019re right in front of their servers<\/b><span style=\"font-weight: 400;\">. Follow this guide to import a MySQL database to your server remotely.<\/span><\/p>\n\n\n\n<p><b>Log in<\/b><span style=\"font-weight: 400;\"> to your FTP client to upload the file you want to import into the database. Let\u2019s assume you saved the file as <\/span><i><span style=\"font-weight: 400;\">dbimport.sql<\/span><\/i><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"551\" height=\"360\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_43.png\" alt=\"How to Import and Export a MySQL Database, Method 2: Using Command Line\" class=\"wp-image-1057\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_43.png 551w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h31_43-300x196.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><span style=\"font-weight: 400;\">Log in to your hosting account using SSH.&nbsp;<\/span><\/p>\n\n\n\n<p><b>Navigate to the directory where you uploaded the file<\/b><span style=\"font-weight: 400;\">,&nbsp;using the <em>cd<\/em> command.<i><\/i><\/span><i><\/i><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Use this command to import the file to your database: <\/span><i><span style=\"font-weight: 400;\">mysql -u username -p dbname &lt; dbimport.sql<\/span><\/i> <span style=\"font-weight: 400;\">.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Username and dbname in the above command should be your database\u2019s username and name, respectively.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>How to Export a MySQL Database<\/b><\/h2>\n\n\n\n<p>Databases can also be exported through both phpMyAdmin and the command line.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Method 1: Using PhpMyAdmin<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">To export your database using PhpMyAdmin, then <\/span><b>log into SPanel&#8217;s User Interface and open phpMyAdmin<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"461\" height=\"163\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_08.png\" alt=\"How to Import and Export a MySQL Database, Method 1: Using PhpMyAdmin\" class=\"wp-image-1059\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_08.png 461w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_08-300x106.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><span style=\"font-weight: 400;\">Click <\/span><b>Export<\/b><span style=\"font-weight: 400;\"> on the top bar.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"603\" height=\"266\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_17.png\" alt=\"How to Import and Export a MySQL Database, Method 1: Using PhpMyAdmin 2\" class=\"wp-image-1060\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_17.png 603w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_17-300x132.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><span style=\"font-weight: 400;\">Click on the \u201c<\/span><b>Custom<\/b><span style=\"font-weight: 400;\">\u201d radio button to list all the databases on the server. <\/span><b>Choose the export format<\/b><span style=\"font-weight: 400;\">, then select the database you intend to export.<\/span><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"476\" height=\"468\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_40.png\" alt=\"How to Import and Export a MySQL Database, Method 1: Using PhpMyAdmin 3\" class=\"wp-image-1061\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_40.png 476w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2021\/03\/2021-03-17_10h32_40-300x295.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<p><b>Configure the export options<\/b><span style=\"font-weight: 400;\"> and click on the \u201c<\/span><b>Go<\/b><span style=\"font-weight: 400;\">\u201d button to export the file to your computer.<\/span><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><b>Method 2: Using Command Line<\/b><\/h3>\n\n\n\n<p><span style=\"font-weight: 400;\">Using phpMyAdmin places a limit on the file size you can export. The command line <\/span><b>provides a safe and efficient way<\/b><span style=\"font-weight: 400;\"> to export both small and large databases.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Here\u2019s how to export a database using the command line.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Log in to your server <\/span><b>remotely<\/b><span style=\"font-weight: 400;\"> using SSH.<\/span><i><\/i><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Use this command <\/span><i><span style=\"font-weight: 400;\">mysqldump &#8211;routines -u username -p dbname &gt; dbexport.sql <\/span><\/i><span style=\"font-weight: 400;\">&nbsp;to export the database. Replace \u201cusername\u201d and \u201cdbname\u201d in the command with the username and database name of the database you want to export.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Replace <\/span><i><span style=\"font-weight: 400;\">dbexport.sql<\/span><\/i><span style=\"font-weight: 400;\"> with the file name and format you want to export the database to. When prompted, <\/span><b>enter the user&#8217;s password to run the export<\/b><span style=\"font-weight: 400;\">. The database export will reside in your server in the file name and format you specified.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Connect remotely to the server <\/span><a href=\"https:\/\/www.scalahosting.com\/kb\/how-to-connect-to-my-vps-via-sftp\/\"><b>using FTP<\/b><\/a><span style=\"font-weight: 400;\"> to download the file to your local computer.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article provides a quick guide on how to import and export a MySQL database. We\u2019ll be guiding you through all you need to know to run these simple tasks. You can create MySQL databases and set up MySQL users via the MySQL databases tool available in SPanel&#8217;s User Interface. And here\u2019s how to import [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_seopress_analysis_target_kw":"","footnotes":""},"categories":[27],"tags":[],"class_list":["post-1050","post","type-post","status-publish","format-standard","hentry","category-vps-hosting"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/1050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/comments?post=1050"}],"version-history":[{"count":8,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/1050\/revisions"}],"predecessor-version":[{"id":5655,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/1050\/revisions\/5655"}],"wp:attachment":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/media?parent=1050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/categories?post=1050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/tags?post=1050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}