{"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-03-16T12:12:12","modified_gmt":"2026-03-16T12:12:12","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\">There might be a situation when your VPS cannot be started. If you are trying to recover MySQL databases from <b>VPS Recovery Mode<\/b> or <b>VPS backup files<\/b>, follow these steps:<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_7ffae3b376\">Step 1 &ndash; Install and stop MySQL server<\/h2><p class=\"no-margin\"><b><a href=\"\/support\/5723772-how-to-connect-to-your-vps-via-ssh\" target=\"_blank\" class=\"intercom-content-link\">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\">\n<\/p><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\">\n<\/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><p class=\"no-margin\">\n<\/p><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\">\n<\/p><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\">\n<\/p><p class=\"no-margin\">When all is good to go, <b>start your MySQL server<\/b>:<\/p><pre><code>service mysql start<\/code><\/pre><p class=\"no-margin\">\n<\/p><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\">\n<\/p><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><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">That&rsquo;s it. Now, your databases have been fully recovered!<\/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-PT","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-----mysql---\/","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":0,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1155\/revisions"}],"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}]}}