To change the data directory location for PostgreSQL after installation
To change the data directory location for PostgreSQL after installation, you'll need to move the existing data to the new location and update PostgreSQL's configuration to use the new directory. Here’s a step-by-step guide to achieve that: 1. Stop PostgreSQL service : First, stop the PostgreSQL service to ensure no data is being accessed or written during the move. sudo systemctl stop postgresql-15 2. Create the new data directory : Create the new directory where you want to move your PostgreSQL data, and set the appropriate permissions for the postgres user. sudo mkdir -p /new/postgres/pg_data sudo chown postgres:postgres /new/postgres/pg_data sudo chmod 700 /new/postgres/pg_data 3. Move the existing data : Move your existing data from the old directory to the new directory. This step will ensure all your current databases and configurations are preserved. sudo rsync -av --progress /var/lib/pgsql/15/data/ /new/postgres/pg_data/ The rsync command helps preserve permission...
Comments
Post a Comment