This article covers:
- Update Magento 2.3 Base URL in MySQL
- A culprit of flushing Magento 2 cache in command line
Audiences of this article:
- Magento 2.3 developers
Find the rows of base_url in core_config_data Table
Both secure and unsecure base_url are located in table core_config_data. If you’re not familiar with core_config_data structure, use MySQL LIKE operator to find the rows contain keyword ‘secure’:
select * from core_config_data where path like '%secure%';
This gives you the column names and config_id of both web/unsecure/base_url and web/secure/base_url. See results below:
+-----------+---------+----------+-----------------------------------+------------------------+ | config_id | scope | scope_id | path | value | +-----------+---------+----------+-----------------------------------+------------------------+ | 2 | default | 0 | web/unsecure/base_url | https://mystore.com.au/ | | 238 | default | 0 | payment/braintree/verify_3dsecure | 0 | | 621 | default | 0 | web/unsecure/base_static_url | NULL | | 622 | default | 0 | web/unsecure/base_media_url | NULL | | 623 | default | 0 | web/secure/base_url | https://mystore.com.au/ | | 624 | default | 0 | web/secure/base_static_url | NULL | | 625 | default | 0 | web/secure/base_media_url | NULL | +-----------+---------+----------+-----------------------------------+------------------------+ 7 rows in set (0.00 sec)
Update Both base_url Values
Notice the two config_id in my case is ‘2’ and ‘623’, yours maybe different! We can then use MySQL UPDATE statement to complete this:
update core_config_data set value = 'http://shop.eharvest.com.au/' where config_id = '2'; update core_config_data set value = 'http://shop.eharvest.com.au/' where config_id = '623';
Once done, you can use above like operator to check if there URLs have been updated successfully
select * from core_config_data where path like '%secure%';
Then flush Magento cache, you should be good to go. Remember it’s always a good idea to perform a database backup before using MySQL statements to alter Magento database.
bin/magento cache:flush ## Always a good idea to check cache status after flushing your cache in command line! bin/magento cache:status
The Culprit of Flushing Magento 2 Cache in Command Line
We noticed that sometimes, when flushing Magento cache, it also disables all Magento cache. If you’re in developer mode, without knowing this culprit is likely to be disastrous as disabled cache in Magento 2 developer mode will cause CPU high load. Leaving you scratching your head trying to figure it out. Therefore, it’s always a good habit to check cache status after flushing them.