{"id":1351,"date":"2020-11-16T10:02:24","date_gmt":"2020-11-16T10:02:24","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/11\/16\/move-magento-2-from-localhost-to-server\/"},"modified":"2025-08-25T17:09:51","modified_gmt":"2025-08-25T11:39:51","slug":"move-magento-2-from-localhost-to-server","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/move-magento-2-from-localhost-to-server\/","title":{"rendered":"How to Move Magento 2 from Localhost to Server"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2 store setup can be complicated. You may not want to offer a half baked setup to your potential customers only to disappoint them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The solution is to first set up the Magento 2 store in localhost. You may have spent hours building your store.&nbsp;Once you finish implementing and configuring every feature, you can go LIVE!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before moving to learn the steps, make sure you have purchased domain and\u00a0<a href=\"https:\/\/meetanshi.com\/blog\/magento-hosting-providers\/\" target=\"_blank\" rel=\"noreferrer noopener\">best Magento hosting<\/a>\u00a0as well.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This post shows the method to<strong>&nbsp;move Magento 2 from localhost to server<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Move Magento 2 from Localhost to Server:<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1:&nbsp;Export Database from Localhost<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">1. Connect to localhost software like XAMPP, WAMP etc and login to phpMyAdmin<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Visit the store\u2019s database<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. At the top of the menu, click&nbsp;<strong>Export&nbsp;<\/strong>then hit&nbsp;<strong>Go<\/strong>&nbsp;button.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/11\/1-1024x381.png\" alt=\"Magento 1 export option\" class=\"wp-image-11438\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now, you will be able to download the database files as the<strong>&nbsp;.sql&nbsp;<\/strong>extension. You can also save it in&nbsp;<strong>.zip<\/strong>&nbsp;form.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Make Magento Files in Zip Format<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Select all the files and folders from localhost and make a zip file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Go to htdocs folder (if you are using XAMPP) or www folder (if WAMPP)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Navigate to Magento folder and compress the files in zip format<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Uploading Magento Files to Web Server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For uploading database, you need to upload via cPanel that is your website server. But before that, you need to create a user and give database rights.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Login to cPanel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Go to phpMyAdmin<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. In phpMyAdmin, create a new database by clicking on the new button. Make sure you remember database name, username and password.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Import Database<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After creating a database, you need to import the database file which you have downloaded in step 1.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can leverage two methods for importing the database.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first method for importing the database is by using the command line.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -p -u username database_name &lt; backup_file.sql<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The second method for importing the database is by using PHPMYADMIN.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Find out the&nbsp;<strong>Import&nbsp;<\/strong>option at the top of the menu and click on it<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. To import the database, hit&nbsp;<strong>Choose File<\/strong>&nbsp;and upload a file having .<strong>sql<\/strong>&nbsp;extension<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/11\/2-1024x531.png\" alt=\"Magento 1 import option\" class=\"wp-image-11439\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure to select the correct character set to avoid the&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/error-1273-unknown-collation-utf8mb4-0900-ai-ci-in-mysql\/\" target=\"_blank\" rel=\"noreferrer noopener\">unknown collation error in MySQL<\/a>&nbsp;during the import process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Upload Magento Files<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can also create a subfolder for a new domain. If you do not wish to do, you can continue with normal directory also.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Upload the zip file and extract that you created in step 3.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Change env.php file for Accessing the Magento System to New Database<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once you finish uploading the zip folder with extraction, you will now need to make changes in env.php file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Go to&nbsp;<strong>app\/etc\/env.php<\/strong>. In env.php file,&nbsp;you will have to make changes related to the information of the new database that you just created on your domain. Make changes in a username, name and password while importing the database to your new domain. Locate in the file where this information is suitable. You will find something like the below image.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Find Out your New Domain Name for Magento System<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After the completion of step 6, you need to make save the changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Click&nbsp;<strong>Save<\/strong>&nbsp;in the top right<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. If you wish to select and edit the file, you need to upload it again to the right directory. For that, go to the Magento database and search&nbsp;<strong>Table Core_Config_Data.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. Replace localhost URL to domain name in&nbsp;<strong>\u201cweb\/unsecure\/base_url\u201d<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/11\/5-1024x240.png\" alt=\"2020\/11\/5.png\" class=\"wp-image-11445\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 8: Run Below Commands<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run all the below commands and you will manage to access your Magento store.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php bin\/magento setup:upgrade\nphp bin\/magento setup:static-content:deploy -f\nphp bin\/magento cache:flush\nphp bin\/magento cache:clean<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Share this post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2 store setup can be complicated. You may not want to offer a half baked setup to your potential customers only to disappoint them&#8230;.<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1351","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1351"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1351\/revisions"}],"predecessor-version":[{"id":20746,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1351\/revisions\/20746"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}