Magento Open Source, 1.9.x
Media Storage Database Setup

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 local.xml file.

To use a database for media storage:

1. On the Admin menu, select System > Configuration.
2. In the panel on the left, under Advanced, select System.
3. This configuration takes place at the global level, so set Current Configuration Scope to “Default Config.”
4. Click to expand the Storage Configuration for Media section. Then, do the following:
a. Set Media Storage to “Database.”
b. Set Select Media Database to the database you want to use.
c. Click the Synchronize button to transfer the existing media to the newly selected database.
d. Enter the Environment Update Time in seconds.
5. When complete, click the Save Config button.