{"id":3128,"date":"2020-03-11T12:53:38","date_gmt":"2020-03-11T17:53:38","guid":{"rendered":"http:\/\/bluegalaxy.info\/codewalk\/?p=3128"},"modified":"2020-03-11T12:53:40","modified_gmt":"2020-03-11T17:53:40","slug":"mysql-how-to-copy-database-from-web-host-to-localhost","status":"publish","type":"post","link":"https:\/\/bluegalaxy.info\/codewalk\/2020\/03\/11\/mysql-how-to-copy-database-from-web-host-to-localhost\/","title":{"rendered":"MySQL: How to copy database from web host to localhost"},"content":{"rendered":"\n<p>Let&#8217;s say you want to copy the MySQL database used on a website to a local installation of PHP\/MySQL for testing. In order to do this, you will need the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Access to the cpanel of the website that has phpMyAdmin installed<\/li><li>An Apache server with phpMyAdmin installed locally. For this, you can use Bitnami&#8217;s <a href=\"https:\/\/bitnami.com\/stack\/wamp\/installer\">WAMP<\/a> stack if you&#8217;re on Windows, or their <a href=\"https:\/\/bitnami.com\/stack\/mamp\/installer\">MAMP<\/a> installation package if you&#8217;re developing on a Mac. <\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Export the website database<\/h3>\n\n\n\n<p>Once you have logged into the website cpanel, click to open the phpMyAdmin.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1024x992.png\" alt=\"\" class=\"wp-image-3130\" width=\"542\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1024x992.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-300x291.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-768x744.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-676x655.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image.png 1084w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Inside the phpMyAdmin tool, select the database that you want to copy (on the left) and then click the Export tab and choose the SQL format option. Then click the &#8220;Go&#8221; button. For example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1-1024x475.png\" alt=\"\" class=\"wp-image-3131\" width=\"891\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1-1024x475.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1-300x139.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1-768x356.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1-1536x712.png 1536w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1-676x313.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-1.png 1782w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Then in the dialog box that pops up, choose &#8220;Save File&#8221; to save the database.sql file to your hard drive. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-2.png\" alt=\"\" class=\"wp-image-3137\" width=\"374\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-2.png 748w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-2-300x265.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-2-676x596.png 676w\" sizes=\"(max-width: 748px) 100vw, 748px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Step 2: Import the database locally<\/h3>\n\n\n\n<p>First, log into your local phpMyAdmin tool. In my case it was at 127.0.0.1:8080\/phpmyadmin:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-3-1024x1020.png\" alt=\"\" class=\"wp-image-3139\" width=\"525\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-3-1024x1020.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-3-300x300.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-3-150x150.png 150w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-3-768x765.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-3-676x673.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-3.png 1050w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Then, when inside phpMyAdmin, create a new database to house the database copy that you are going to be importing. Note: I gave my database the exact same name as it has on the website. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-4-1024x412.png\" alt=\"\" class=\"wp-image-3140\" width=\"522\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-4-1024x412.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-4-300x121.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-4-768x309.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-4-676x272.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-4.png 1044w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>With the new database created locally, it should appear on the left and it will be an empty database with no tables yet. For example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-5.png\" alt=\"\" class=\"wp-image-3142\" width=\"468\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-5.png 936w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-5-300x171.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-5-768x438.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-5-676x386.png 676w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/figure>\n\n\n\n<p>Now that the empty database exists locally, we can import the database that we exported from the website. Select the new empty database, click the &#8220;Import&#8221; tab, then &#8220;Choose File&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-6-1024x458.png\" alt=\"\" class=\"wp-image-3143\" width=\"875\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-6-1024x458.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-6-300x134.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-6-768x343.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-6-1536x686.png 1536w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-6-676x302.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-6.png 1750w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After selecting the exported database, click &#8220;Go&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-7-987x1024.png\" alt=\"\" class=\"wp-image-3144\" width=\"775\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-7-987x1024.png 987w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-7-289x300.png 289w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-7-768x797.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-7-1481x1536.png 1481w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-7-676x701.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-7.png 1550w\" sizes=\"(max-width: 987px) 100vw, 987px\" \/><\/figure>\n\n\n\n<p>When the import process completes, there should be a success message. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-9-1024x92.png\" alt=\"\" class=\"wp-image-3146\" width=\"569\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-9-1024x92.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-9-300x27.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-9-768x69.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-9-676x61.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-9.png 1138w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Success! Now you should also see the imported database tables. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-10.png\" alt=\"\" class=\"wp-image-3147\" width=\"225\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-10.png 450w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/03\/image-10-157x300.png 157w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s say you want to copy the MySQL database used on a website to a local installation of PHP\/MySQL for testing. In order to do this, you will need the following: Access to the cpanel of the website that has phpMyAdmin installed An Apache server with phpMyAdmin installed locally. For this, you can use Bitnami&#8217;s &hellip; <a href=\"https:\/\/bluegalaxy.info\/codewalk\/2020\/03\/11\/mysql-how-to-copy-database-from-web-host-to-localhost\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">MySQL: How to copy database from web host to localhost<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112],"tags":[108],"class_list":["post-3128","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql"],"_links":{"self":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/comments?post=3128"}],"version-history":[{"count":9,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3128\/revisions"}],"predecessor-version":[{"id":3148,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3128\/revisions\/3148"}],"wp:attachment":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/media?parent=3128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/categories?post=3128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/tags?post=3128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}