{"id":6911,"date":"2019-12-12T05:48:14","date_gmt":"2019-12-12T05:48:14","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=6911"},"modified":"2019-12-12T05:55:20","modified_gmt":"2019-12-12T05:55:20","slug":"how-to-import-export-mysql-database-via-command-line-ssh","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/","title":{"rendered":"How to Import and Export MySQL Database via Command Line (SSH)?"},"content":{"rendered":"<p>If you are an advanced user, you may wish to use SSH to access and make changes to your account, as it offer a more robust set of options with less limitations. For this, you need to have a basic idea about SSH.<\/p>\n<h3>Steps to Import Your Database from the Command Line:<\/h3>\n<div class=\"kb-wisdom-wrapr kb-wisdom-info kb-wisdom-wrapr-blue\">\n<div class=\"kb-wisdom-col kb-wisdom-col-icon\">\n<div class=\"kb-wisdom-icon\">\n<div><\/div>\n<\/div>\n<\/div>\n<div class=\"kb-wisdom-col kb-wisdom-col-content\">\n<p><strong>Note:<\/strong> Make sure your database file is in .sql format, it cannot be compressed in a .zip or .tar.gz.<\/p>\n<\/div>\n<\/div>\n<ol>\n<li>At first, login to SSH upload your database to your home directory (You can do this using cPanel File Manager, an FTP client, or SSH).<\/li>\n<li>In case the database isn\u2019t available, please create a database, a user, and give the user complete privileges to the database. Take a note of the username and password.<\/li>\n<li>Then log into your server using SSH.<\/li>\n<li>With the ls -l command, verify that the file is present in your current directory.<\/li>\n<li>In case the file isn\u2019t available, upload\/move the file to the correct directory, or go to the directory where the file is located.<\/li>\n<li>Enter the below command and replace &#8216;user_name&#8217;, &#8216;database_name, and &#8216;file.sql&#8217; with your username, database name and file:\n<pre class=\"lang:default decode:true \">mysql -p -u user_name database_name &lt; file.sql<\/pre>\n<\/li>\n<li>You will be asked for your database user password, and then your database will be imported.<\/li>\n<\/ol>\n<h3>Steps to Export Database from the Command Line<\/h3>\n<ol>\n<li>Open the command line on the computer where the database is stored. For example, if your database is on another web hosting account or with another web hosting provider, use SSH and log in to the account. In case you have physical access to the computer, open a DOS or terminal window to access the command line.<\/li>\n<li>Type the below command, and then press Enter. Replace username with your username, and dbname with the database name that you want to export:\n<pre class=\"lang:default decode:true \">mysqldump -u username -p dbname &gt; dbexport.sql<\/pre>\n<div class=\"kb-wisdom-wrapr kb-wisdom-info kb-wisdom-wrapr-blue\">\n<div class=\"kb-wisdom-col kb-wisdom-col-icon\">\n<div class=\"kb-wisdom-icon\">\n<div><\/div>\n<\/div>\n<\/div>\n<div class=\"kb-wisdom-col kb-wisdom-col-content\">\n<p><strong>Note:<\/strong> In this example, the dbexport.sql filename is used for the exported database, but you can name the file with the one you want.<\/p>\n<\/div>\n<\/div>\n<\/li>\n<li>Enter your password at the Enter password prompt.<\/li>\n<li>The dbexport.sql file now comprise of all the data for the dbname database. If the dbexport.sql file is located on a remote computer, download the file to your local computer.<\/li>\n<\/ol>\n<p>In this way, you can import and export your database via command line.<\/p>\n<p><strong>Also Read:<\/strong><\/p>\n<p><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/import-export-mysql-database-phpmyadmin\/\" target=\"_blank\" rel=\"noopener\">How to Import and Export the MySQL Database with phpMyAdmin?<\/a><\/p>\n<p><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/mysql-database-import-is-failing-reason-the-sql-file-is-too-big\/\" target=\"_blank\" rel=\"noopener\">MySQL Database Import Is Failing, Reason: The .sql File Is Too Big<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are an advanced user, you may wish to use SSH to access and make changes to your account, as it offer a more robust set of options with less limitations. For this, you need to have a basic idea about SSH. Steps to Import Your Database from the Command Line: Note: Make sure [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[230],"tags":[887,1152,1155,1153,1154],"class_list":["post-6911","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-database","tag-command-line","tag-database","tag-export-mysql-database","tag-import-and-export-database","tag-import-mysql-database"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Import and Export MySQL Database via Command Line (SSH)?<\/title>\n<meta name=\"description\" content=\"The article reveals steps to import and export mysql database via command line.\" \/>\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.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Import and Export MySQL Database via Command Line (SSH)?\" \/>\n<meta property=\"og:description\" content=\"The article reveals steps to import and export mysql database via command line.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-12T05:48:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-12T05:55:20+00:00\" \/>\n<meta name=\"author\" content=\"Pallavi Godse\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pallavi Godse\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/\",\"name\":\"How to Import and Export MySQL Database via Command Line (SSH)?\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"datePublished\":\"2019-12-12T05:48:14+00:00\",\"dateModified\":\"2019-12-12T05:55:20+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\"},\"description\":\"The article reveals steps to import and export mysql database via command line.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Import and Export MySQL Database via Command Line (SSH)?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\",\"name\":\"Pallavi Godse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g\",\"caption\":\"Pallavi Godse\"},\"description\":\"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/pallavi\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Import and Export MySQL Database via Command Line (SSH)?","description":"The article reveals steps to import and export mysql database via command line.","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.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/","og_locale":"en_GB","og_type":"article","og_title":"How to Import and Export MySQL Database via Command Line (SSH)?","og_description":"The article reveals steps to import and export mysql database via command line.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2019-12-12T05:48:14+00:00","article_modified_time":"2019-12-12T05:55:20+00:00","author":"Pallavi Godse","twitter_misc":{"Written by":"Pallavi Godse","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/","name":"How to Import and Export MySQL Database via Command Line (SSH)?","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"datePublished":"2019-12-12T05:48:14+00:00","dateModified":"2019-12-12T05:55:20+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945"},"description":"The article reveals steps to import and export mysql database via command line.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-import-export-mysql-database-via-command-line-ssh\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How to Import and Export MySQL Database via Command Line (SSH)?"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945","name":"Pallavi Godse","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g","caption":"Pallavi Godse"},"description":"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/pallavi\/"}]}},"views":613,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=6911"}],"version-history":[{"count":2,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6911\/revisions"}],"predecessor-version":[{"id":6914,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6911\/revisions\/6914"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=6911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=6911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=6911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}