{"id":3440,"date":"2019-10-25T10:48:42","date_gmt":"2019-10-25T02:48:42","guid":{"rendered":"https:\/\/www.mondoze.com\/guide\/?post_type=kb&#038;p=3440"},"modified":"2022-10-07T07:49:33","modified_gmt":"2022-10-06T23:49:33","slug":"export-and-import-database-from-linux-terminal-ssh","status":"publish","type":"kb","link":"https:\/\/www.mondoze.com\/guide\/kb\/export-and-import-database-from-linux-terminal-ssh","title":{"rendered":"Export and import database from linux terminal (SSH)"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3440\" class=\"elementor elementor-3440\" data-elementor-settings=\"[]\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7861369c elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7861369c\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-792c20a7\" data-id=\"792c20a7\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-c85aa36 elementor-widget elementor-widget-heading\" data-id=\"c85aa36\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">How To Export and Import Database from Linux Terminal<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-12206b29 elementor-widget elementor-widget-text-editor\" data-id=\"12206b29\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t<p><strong><span style=\"font-size: medium;\">Applies to :<\/span><\/strong><\/p><ul><li>All Linux server<\/li><\/ul><p><strong><span style=\"font-size: medium;\">Requirements<\/span><\/strong><\/p><p>To perform this task, you need to have :<\/p><ul><li>Knowledge in accessing the server via\u00a0SSH.<\/li><li>IP address or server hostname.<\/li><li>Your server SSH\/FTP username and password.<\/li><\/ul><p><strong><span style=\"font-size: medium;\">Instructions<\/span><\/strong><\/p><p>This method is an alternative way to export and import your database when you have difficulties to import it via PHPMyAdmin panel due to big *.sql file size. Please follow below steps in order to export and import your database via Linux command line :<\/p><ul><li>Initiate SSH connection to your Linux server.<\/li><\/ul><ul><li>Use\u00a0<strong>cd<\/strong>\u00a0command to change your directory location to a directory where your user has write access. For example (replace xxxx with your username) :<\/li><\/ul><pre> # cd \/home\/xxxx\/data\/\n\n<\/pre><ul><li>You can export the database (i.e. dbname) by run the following command:<\/li><\/ul><pre> # mysqldump --add-drop-table -u username -p dbname &gt; dbname.sql \n\n<\/pre><p>After you executed the above command, you will be prompted for your database password. Type in the password and hit enter. Your database will now start exporting. When it is done, you will see the command prompt again. If it is a large database, this may take a few minutes.<\/p><pre>NOTE: \nThe following variables need to be replaced with your own information: \n-u username : specifies the database username. \n-p : designates that you will be entering a password. \ndbname : the name of the database you are trying to export. \ndbname.sql : the name you want to give your backup file, and can be whatever you want. \nOmit the --add-drop-table argument if you plan to merge this backup with an existing database when you import it. This option means the backup will totally replace the old database when it is imported.\n\n<\/pre><p>You can now download the resulting SQL file. Connect to your server with FTP, navigate to the directory where you created the dump file, and\u00a0download it. If you created the SQL file in a web-accessible directory, such as your html folder, you should delete it after downloading a copy.\u00a0Otherwise, anyone can download it from the web.<\/p><ul><li>To import a database from a *.sql file you can run below command :<\/li><\/ul><pre> # mysql -u username -p dbname &lt; dbname.sql\n\n<\/pre><ul><li>If you got below error :<\/li><\/ul><pre>Got Error: 1045: Access denied for user 'username' (using password: YES) when trying to connect\n\n<\/pre><p>This means you have entered an incorrect password. Please retype it carefully, or reset your password via your plesk control panel (if you are in Plesk platform)<\/p>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>How To Export and Import Database from Linux Terminal Applies to : All Linux server Requirements To perform this task, you need to have : Knowledge in accessing the server via\u00a0SSH. IP address or server hostname. Your server SSH\/FTP username and password. Instructions This method is an alternative way to export and import your database &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.mondoze.com\/guide\/kb\/export-and-import-database-from-linux-terminal-ssh\"> <span class=\"screen-reader-text\">Export and import database from linux terminal (SSH)<\/span> Read More \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}}},"kbtopic":[123],"kbtag":[110],"mkb_version":[],"_links":{"self":[{"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/kb\/3440"}],"collection":[{"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/comments?post=3440"}],"version-history":[{"count":7,"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/kb\/3440\/revisions"}],"predecessor-version":[{"id":21916,"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/kb\/3440\/revisions\/21916"}],"wp:attachment":[{"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/media?parent=3440"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=3440"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/kbtag?post=3440"},{"taxonomy":"mkb_version","embeddable":true,"href":"https:\/\/www.mondoze.com\/guide\/wp-json\/wp\/v2\/mkb_version?post=3440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}