{"id":30089,"date":"2021-01-18T03:10:01","date_gmt":"2021-01-17T19:10:01","guid":{"rendered":"https:\/\/web.mwwsb.com.my\/pjci\/?post_type=kb&#038;p=30089"},"modified":"2022-09-08T21:35:12","modified_gmt":"2022-09-08T13:35:12","slug":"managing-databases-with-command-line-ssh","status":"publish","type":"kb","link":"https:\/\/www.casbay.com\/guide\/kb\/managing-databases-with-command-line-ssh","title":{"rendered":"Managing Databases with Command Line SSH"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"30089\" class=\"elementor elementor-30089\" data-elementor-post-type=\"kb\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-acbba1e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"acbba1e\" 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<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-93bf6e0\" data-id=\"93bf6e0\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a71cb01 elementor-widget elementor-widget-heading\" data-id=\"a71cb01\" 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\">Managing Databases with Command Line SSH<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-98b62ff elementor-widget elementor-widget-text-editor\" data-id=\"98b62ff\" 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<p>Using SSH can be a superior way to manage the files and databases on your account. Using a simple command you can import or export a MySQL database into an existing database on your account.<\/p><p>Please note that in the examples below the\u00a0<strong>-p<\/strong>\u00a0will prompt for your account\u2019s password. And that your database name needs to include your username, e.g.\u00a0<strong>examplec_<\/strong>database.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b66d1ce elementor-widget elementor-widget-heading\" data-id=\"b66d1ce\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Exporting MySQL Data<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ac10909 elementor-widget elementor-widget-text-editor\" data-id=\"ac10909\" 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<p>This example shows you how to export a database. It is a good idea to export your data often as a backup.<\/p><ol><li>Using <strong>SSH<\/strong>, execute the following command:<pre><strong><code>mysqldump -p -u username database_name &gt; dbname.sql<\/code> <\/strong><\/pre><\/li><li>You will be prompted for a password, type in the password for the username and press <strong>Enter<\/strong>. Replace username, password, and database_name with your MySQL username, password, and database name.<\/li><\/ol><p>The file dbname.sql now holds a backup of your database and is ready for download to your computer.<\/p><p>To export a single table from your database you would use the following command:<\/p><pre><strong><code>mysqldump -p --user=username database_name tableName &gt; tableName.sql<\/code><\/strong><\/pre><p>Again you would need to replace the username, database and tableName with the correct information.<\/p><p>Once done the table specified would then be saved to your account as\u00a0<strong>tableName.sql<\/strong><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ee02cef elementor-widget elementor-widget-heading\" data-id=\"ee02cef\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Import A MySQL Database<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-533f7a0 elementor-widget elementor-widget-text-editor\" data-id=\"533f7a0\" 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\tThe file must be in .sql format. It cannot be compressed in a .zip or .tar.gz file.\n<br><br>\n<ol>\n \t<li>Start by <strong>uploading the .sql file<\/strong> onto the server.<\/li><br>\n \t<li>If you haven\u2019t already done so, <strong>create the MySQL database<\/strong> via the cPanel.<\/li><br>\n \t<li>Using SSH, navigate to the directory where your .sql file is.<\/li><br>\n \t<li>Next, run this command:\n<pre><strong><code> mysql -p -u username database_name &lt; file.sql <\/code><\/strong><\/pre><\/li>\n\n\n \t<li>Lastly, to import a single table into an existing database you would use the following command:\n<pre><strong><code>mysql -u username -p -D database_name &lt; tableName.sql<\/code><\/strong><\/pre><\/li><\/ol>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cb85063 elementor-widget elementor-widget-text-editor\" data-id=\"cb85063\" 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<p>Check out the next article on <a href=\"https:\/\/www.casbay.com.my\/guide\/kb\/check-server-hack-and-exim-spamming\/\">How to Check Server hack and exim spamming<\/a>.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Managing Databases with Command Line SSH Using SSH can be a superior way to manage the files and databases on your account. Using a simple command you can import or export a MySQL database into an existing database on your account. Please note that in the examples below the\u00a0-p\u00a0will prompt for your account\u2019s password. And [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","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":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","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":"default","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":[117,60],"kbtag":[106],"mkb_version":[],"_links":{"self":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30089"}],"collection":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/comments?post=30089"}],"version-history":[{"count":1,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30089\/revisions"}],"predecessor-version":[{"id":32043,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30089\/revisions\/32043"}],"wp:attachment":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/media?parent=30089"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=30089"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtag?post=30089"},{"taxonomy":"mkb_version","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/mkb_version?post=30089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}