Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save database on external hard drive

Tags:

sql

postgresql

I am creating some databases using PostgreSQL but I want to save them on an external hard drive due to lack of memory in my computer.

How can I do this?

like image 441
Estefy Avatar asked Jun 16 '26 12:06

Estefy


1 Answers

You can store the database on another disk by specifying it as the data_directory setting. You need to specify this at startup and it will apply to all databases.

You can put it in postgresql.conf:

data_directory = '/volume/path/'

Or, specify it on the command line when you start PostgreSQL:

postgres -c data_directory='/volume/path/'

Reference: 18.2. File Locations