{"id":1155,"date":"2020-11-17T13:28:43","date_gmt":"2020-11-17T13:28:43","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2020\/11\/17\/4635603-how-to-recover-mysql-databases-from-mysql-data-files-in-vps-at-hostinger\/"},"modified":"2026-10-09T07:26:14","modified_gmt":"2026-10-09T07:26:14","slug":"4635603-how-to-recover-mysql-databases-from-mysql-data-files-in-vps-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/4635603-how-to-recover-mysql-databases-from-mysql-data-files-in-vps-at-hostinger\/","title":{"rendered":"How to recover MySQL databases from MySQL data files in VPS at Hostinger"},"content":{"rendered":"<p class=\"no-margin\">To recover MySQL databases from MySQL data files on a Hostinger VPS, install and stop a MySQL server, copy the old data to \/var\/lib\/mysql, fix the file ownership, then check, repair, and export the databases. Use this method when your VPS can&rsquo;t start and you&rsquo;re recovering from VPS Recovery Mode or VPS backup files.<\/p><h2 id=\"h_7ffae3b376\">Step 1 &ndash; Install and stop MySQL server<\/h2><p class=\"no-margin\"><b><a data-click-id=\"hgr-post-content-link-connect-to-your-vps-via-ssh\" class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/5723772-how-to-connect-to-your-vps-via-ssh-at-hostinger\/\" target=\"_blank\" rel=\"noopener\">Connect to your VPS via SSH<\/a><\/b> and install MySQL server by running this command:<\/p><pre><code>yum install mysql-server<\/code><\/pre><p class=\"no-margin\">It&rsquo;s recommended to use <b>the same version of MySQL<\/b>. However, using a newer version is also possible.<\/p><p class=\"no-margin\">After the MySQL server is installed, it&rsquo;s time to<b> stop it<\/b> to add to the data folders:<\/p><pre><code>service mysql stop<\/code><\/pre><h2 id=\"h_1e7c149dfe\">Step 2 &ndash; Copy the data<\/h2><p class=\"no-margin\">Use the following command to copy your old MySQL data to the new MySQL server data files&rsquo; location:<\/p><pre><code>cp -rf \/mnt\/var\/lib\/mysql\/* \/var\/lib\/mysql<\/code><\/pre><p class=\"no-margin\">After the command is executed, verify that the files are owned by the MySQL user. by <b>changing the files&rsquo; ownership<\/b>:<\/p><pre><code>chown -R mysql:mysql \/var\/lib\/mysql<\/code><\/pre><p class=\"no-margin\">When all is good to go, <b>start your MySQL server<\/b>:<\/p><pre><code>service mysql start<\/code><\/pre><h2 id=\"h_ceaa2e1e92\">Step 3 &ndash; Final checks and export<\/h2><p class=\"no-margin\"><b>Check and repair all the database tables <\/b>to ensure no data is corrupted:<\/p><pre><code>mysqlcheck -rA<\/code><\/pre><p class=\"no-margin\"><b>NOTE<\/b><\/p><ul>\n<li>\n<p class=\"no-margin\">Depending on the version of MySQL you are running, you should run MYSQLCHECK<\/p>\n<\/li>\n<\/ul><p class=\"no-margin\">Lastly, <b>export the databases<\/b>:<\/p><pre><code>mysqldump --all-databases &gt; all_databases.sql<\/code><\/pre><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">See <a data-click-id=\"hgr-post-content-link-how-to-back-up-or-restore-a-hostinger-vps\" href=\"https:\/\/www.hostinger.com\/support\/1583232-how-to-back-up-or-restore-a-vps-at-hostinger\/\">How to back up or restore a Hostinger VPS<\/a> for other details about restoring a VPS from a backup.<\/div><p>Your MySQL databases are now recovered and exported to all_databases.sql.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recovering MySQL databases from MySQL data files \/var\/lib\/mysql<\/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":[199],"tags":[],"class_list":["post-1155","post","type-post","status-publish","format-standard","hentry","category-vps-management"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/4635603-how-to-recover-mysql-databases-from-mysql-data-files-in-vps-at-hostinger","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/4635603-como-recuperar-bases-de-datos-mysql-de-archivos-de-datos-mysql-en-vps","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/4635603-comment-recuperer-des-bases-de-donnees-mysql-a-partir-de-fichiers-de-donnees-mysql-dans-un-vps-chez-hostinger","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/4635603-bagaimana-cara-memulihkan-database-mysql-dari-data-file-mysql-di-vps-di-hostinger","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/support\/4635603-como-recuperar-bancos-de-dados-mysql-de-arquivos-de-dados-mysql-em-vps-hostinger","default":0},{"locale":"uk-UA","link":"https:\/\/www.hostinger.com\/ua\/support\/4635603-\u044f\u043a-\u0432\u0456\u0434\u043d\u043e\u0432\u0438\u0442\u0438-\u0431\u0430\u0437\u0443-\u0434\u0430\u043d\u0438\u0445-mysql-\u0437-\u0444\u0430\u0439\u043b\u0443-\u0434\u0430\u043d\u0438","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1155","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=1155"}],"version-history":[{"count":2,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1155\/revisions"}],"predecessor-version":[{"id":20136,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1155\/revisions\/20136"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=1155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=1155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=1155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}