Introduction

Updating secure and unsecure URLs directly in the Magento database can be necessary when you need to modify your website’s base URLs swiftly and efficiently. This method bypasses the Magento admin panel and allows you to edit the configuration stored in the database directly. It’s handy when you’re unable to access the admin panel due to technical issues or when you prefer working directly with the database

Prerequisites

  1. A sudo privileged SSH access to the server
  2. Magento DB credentials
  3. The domain name that we need to update in the DB

Implementation

Step1: SSH the server

$ ssh Username@IP

Step 2: Log in to the MySQL DB with the credentials.

$ mysql -u username -p dbname

Step 3: Switch the DB associated with the Magento panel

> use dbname;

Step 4: Update the secure URL, execute the below query

> UPDATE core_config_data SET value = ‘https://yourdomain.com/’ WHERE path = ‘web/secure/base_url’;

Step 5: Update the unsecure URL, execute the below query

> UPDATE core_config_data SET value = ‘http://yourdomain.com/’ WHERE path = ‘web/unsecure/base_url’;

Note:
Replace http://yourdomain.com/ and https://yourdomain.com/ with the actual unsecure and secure base URLs, respectively.

Step 6: After updating the URLs in the database, it’s a good practice to clear the Magento cache to ensure that the changes take effect

$ php bin/magento cache:flush

Note:
Execute this on the document’s root

Leave a Reply