Uninstall pg_tde¶
If you no longer wish to use TDE in your deployment, you can remove the pg_tde extension. To do so, your user must have the superuser privileges, or a database owner privileges in case you only want to remove it from a single database.
Here’s how to do it:
-
Drop the extension using the
DROP EXTENSIONcommand:DROP EXTENSION pg_tde;This command will fail if there are still encrypted tables in the database.
In this case, you must drop the dependent objects manually. Alternatively, you can run the
DROP EXTENSION ... CASCADEcommand to drop all dependent objects automatically.Note that the
DROP EXTENSIONcommand does not delete thepg_tdedata files related to the database. -
Run the
DROP EXTENSIONcommand against every database where you have enabled thepg_tdeextension, if the goal is to completely remove the extension. This also includes the template databases, in casepg_tdewas previously enabled there. -
Remove any reference to
pg_tdeGUC variables from the PostgreSQL configuration file. -
Modify the
shared_preload_librariesand remove the ‘pg_tde’ from it. Use theALTER SYSTEMcommand for this purpose, or edit the configuration file.Warning
Once
pg_tdeis removed from theshared_preload_libraries, reading any leftover encrypted files will fail. Removing the extension from theshared_preload_librariesis also possible if the extension is still installed in some databases.Make sure to do this only if the server has no encrypted files in its data directory.
-
Start or restart the
postgresqlcluster to apply the changes.- On Debian and Ubuntu:
sudo systemctl restart postgresql- On RHEL and derivatives
sudo systemctl restart postgresql-17