After July 2021, the 2.3.x release line no longer received quality updates or user guide updates. PHP 7.3 reached end of support in December 2021, and Adobe Commerce 2.3.x reached end of support in September 2022. We strongly recommend upgrading to Adobe Commerce 2.4.x to help maintain PCI compliance.

Using a Database

This site contains archived merchant documentation for a version of Adobe Commerce and Magento Open Source that has reached end-of-support. The documentation available here is intended for historical reference only and is not maintained. The Adobe Commerce Merchant Documentation for current releases is published on the Adobe Experience League.

By default, all images, compiled CSS files, and compiled JavaScript files of the Magento instance are stored in the file system on the web server. You can choose to store these files in a database on a database server. One advantage of this approach is the option of automatic synchronization and reverse synchronization between the web server file system and the database. You can use the default database to store media or create a new one. To be able to use a newly created database as media storage, you must add information about it and its access credentials to the env.php file.

Database workflow

  1. Browser requests media - A page from the store opens in the customer’s browser, and the browser requests the media that is specified in the HTML.

  2. System looks for media in file system - The system searches for the media in the file system and if found, passes it to the browser.

  3. System locates media in database - If the media is not found in the file system, a request for the media is sent to the database that is specified in the configuration.

  4. System locates media in database - A PHP script transfers the files from the database to the file system, and sent to the customer’s browser. The browser request for media triggers the script to run as follows:

    • If web server rewrites are enabled for Magento and supported by the server, the PHP script runs only when the requested media is not found in the file system.
    • If web server rewrites are disabled for Magento, or not supported by the server, the PHP script runs anyway, even if the required media is available in the file system.

Use a database for media storage

  1. On the Admin sidebar, go to Stores > Settings > Configuration.

  2. In the left panel, expand Advanced and choose System.

  3. In the upper-left corner, set Store View to Default Config to apply the configuration at the global level.

  4. Expand Expansion selector the Storage Configuration for Media section and do the following:

    Advanced configuration - storage configuration for media Storage Configuration for Media (Database)

    • Set Media Storage to Database.

    • Set Select Media Database to the database you want to use.

    • Click Synchronize to transfer the existing media to the newly selected database.

    • Enter the Environment Update Time in seconds.

  5. When complete, click Save Config.