{"id":1183,"date":"2020-10-14T13:42:14","date_gmt":"2020-10-14T13:42:14","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2020\/10\/14\/4536306-how-to-import-a-database-over-ssh-in-hostinger\/"},"modified":"2026-05-04T05:48:41","modified_gmt":"2026-05-04T05:48:41","slug":"4536306-how-to-import-a-database-over-ssh-in-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/4536306-how-to-import-a-database-over-ssh-in-hostinger\/","title":{"rendered":"How to Import a Database Over SSH in Hostinger"},"content":{"rendered":"<p class=\"no-margin\">phpMyAdmin allows you to <a class=\"intercom-content-link\" href=\"\/support\/1884149-how-to-import-a-database-with-phpmyadmin\" target=\"_blank\" rel=\"noopener\">import databases<\/a> up to <b>256 MB<\/b>, sometimes slightly less if the database has a large number of rows. If importing your database with phpMyAdmin failed, you can use <b>SSH <\/b>instead by following these steps:<\/p><h2 id=\"step-1---preparation\">Step 1 &ndash; Preparations<\/h2><ul>\n<li>\n<p class=\"no-margin\">Upload the database to your website&rsquo;s <b>public_html<\/b> folder &ndash; you can do it <a class=\"intercom-content-link\" href=\"\/support\/1869164-how-to-upload-backup-with-ftp\" target=\"_blank\" rel=\"noopener\">via FTP<\/a><b> <\/b>or with the <b><a class=\"intercom-content-link\" href=\"\/support\/1869114-how-to-upload-backup-with-file-manager\" target=\"_blank\" rel=\"noopener\">File Manager<\/a><\/b><\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><a class=\"intercom-content-link\" href=\"\/support\/1583542-how-can-i-create-a-new-mysql-database\" target=\"_blank\" rel=\"noopener\">Create a new database<\/a> or <a class=\"intercom-content-link\" href=\"\/support\/4536290-how-to-delete-all-database-tables-in-phpmyadmin\" target=\"_blank\" rel=\"noopener\">clear the one you plan to import into<\/a><\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">If you are unsure about the value of your database password, <a class=\"intercom-content-link\" href=\"\/support\/1583522-how-can-i-recover-mysql-password\" target=\"_blank\" rel=\"noopener\">change it<\/a><\/p>\n<\/li>\n<\/ul><h2 id=\"step-2---connecting\">Step 2 &ndash; Connect via SSH<\/h2><ul>\n<li>\n<p class=\"no-margin\">Connect to your <a class=\"intercom-content-link\" href=\"\/support\/1583245-how-can-i-log-in-to-my-account-via-ssh\" target=\"_blank\" rel=\"noopener\">hosting account via SSH<\/a><\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><a class=\"intercom-content-link\" href=\"\/support\/5973000-how-to-open-the-website-s-root-directory-via-ssh\" target=\"_blank\" rel=\"noopener\">Open your root directory<\/a> (<b>public_html<\/b>)<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">If the database backup file is displayed &ndash; go to the next step<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">If you do not see the backup file, double-check using the <b><a class=\"intercom-content-link\" href=\"\/support\/4548688-basic-actions-in-file-manager\" target=\"_blank\" rel=\"noopener\">File Manager<\/a><\/b> that the file is indeed uploaded and placed in the <b>public_html<\/b> folder<\/p>\n<\/li>\n<\/ul><h2 id=\"step-3---import\">Step 3 &ndash; Import the Database<\/h2><p class=\"no-margin\">If the database is in compressed format (<b>.sql.gz<\/b>) use the following command to <b>extract it<\/b> so it&rsquo;s in .sql format:<\/p><pre><code>gzip -d database_name.sql.gz<\/code><\/pre><p class=\"no-margin\">Make sure to replace <b>database_name<\/b> with your database&rsquo;s actual name.<\/p><p class=\"no-margin\">To <b>import the database<\/b>, use this command:<\/p><pre><code>mariadb -u database_username -p database_name &lt; file.sql<\/code><\/pre><p class=\"no-margin\">If the <b>parameters of your database<\/b> are:<\/p><ul>\n<li>\n<p class=\"no-margin\"><b>MySQL Database name<\/b>: u123456789_database<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><b>MySQL Username<\/b>: u123456789_admin<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><b>Uploaded database file<\/b>: database.sql<\/p>\n<\/li>\n<\/ul><p class=\"no-margin\">The command will look like this:<\/p><pre><code>mariadb -u u123456789_admin -p u123456789_database &lt; database.sql<\/code><\/pre><p class=\"no-margin\">After that, you will need to <b>enter the database password<\/b> &ndash; the importing process will start immediately. When it is completed, a new line will appear:<\/p><pre><code>-bash-4.2$<\/code><\/pre><p class=\"no-margin\">Keep in mind that the import will take some time, depending on the size of your database.<\/p><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\"><strong>If you are on an Agency Hosting plan<\/strong>, the command format is slightly different &mdash; the password must be passed inline using the <code class=\"bg-text-200\/5 border border-0.5 border-border-300 text-danger-000 whitespace-pre-wrap rounded-[0.4rem] px-1 py-px text-[0.9rem]\">-p<\/code> flag (no space between the flag and the password), wrapped in single quotes:<\/p><div class=\"relative group\/copy bg-bg-000\/50 border-0.5 border-border-400 rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-100\" role=\"group\" aria-label=\"Code\">\n<div class=\"overflow-x-auto\">\n<pre class=\"code-block__code !my-0 !rounded-lg !text-sm !leading-relaxed p-3.5\"><code>mysql -u database_username -p'database_password' database_name &lt; file.sql<\/code><\/pre>\n<\/div>\n<\/div><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\">Using the same example parameters as above, the command would look like this:<\/p><div class=\"relative group\/copy bg-bg-000\/50 border-0.5 border-border-400 rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-100\" role=\"group\" aria-label=\"Code\">\n<div class=\"overflow-x-auto\">\n<pre class=\"code-block__code !my-0 !rounded-lg !text-sm !leading-relaxed p-3.5\"><code>mysql -u u123456789_admin -p'YourPassword123' u123456789_database &lt; database.sql<\/code><\/pre>\n<\/div>\n<\/div><p class=\"font-claude-response-body break-words whitespace-normal leading-[1.7]\">Note that after running this command, you will <strong>not<\/strong> be prompted to enter your password separately &mdash; the import process will begin immediately.<\/p><h2 id=\"h_2b1aff0fa5\">Step 4 &ndash; Update the Configuration File<\/h2><p class=\"no-margin\">If the database is required for your website to work properly, you will need to update the connection details in your website&rsquo;s <a class=\"intercom-content-link\" href=\"\/support\/3313359-where-to-find-configuration-file-of-my-website\" target=\"_blank\" rel=\"noopener\">configuration file<\/a>.<\/p><p class=\"no-margin\">The specific steps will vary depending on the type of content management system (CMS) you are using. However, in general, you will need to open the configuration file and update the database name, username, password, and host using the <a class=\"intercom-content-link\" href=\"https:\/\/support.hostinger.com\/mysql\/how-can-i-locate-my-mysql-database-details\" target=\"_blank\" rel=\"noopener\">details of the new database<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Importing a database via SSH at Hostinger<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[243],"tags":[],"class_list":["post-1183","post","type-post","status-publish","format-standard","hentry","category-importing-and-exporting-databases"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/4536306-how-to-import-a-database-over-ssh-in-hostinger\/","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/4536306-como-importar-una-base-de-datos-por-ssh-en-hostinger\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/4536306-comment-importer-une-base-de-donnees-via-ssh-chez-hostinger\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/4536306-bagaimana-cara-mengimpor-database-melalui-ssh-di-hostinger\/","default":0},{"locale":"lt-LT","link":"https:\/\/www.hostinger.com\/lt\/support\/4536306-kaip-importuoti-duomenu-baze-per-ssh-hostinger-platformoje\/","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/br\/support\/4536306-como-importar-um-banco-de-dados-por-ssh-na-hostinger\/","default":0},{"locale":"uk-UA","link":"https:\/\/www.hostinger.com\/ua\/support\/4536306------ssh--hostinger\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=1183"}],"version-history":[{"count":4,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1183\/revisions"}],"predecessor-version":[{"id":10230,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1183\/revisions\/10230"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=1183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=1183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=1183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}