Как удалить postgresql linux
Перейти к содержимому

Как удалить postgresql linux

  • автор:

ru-developer

Выполняем последовательность команд. Последовательность избыточна. В зависимости от того, как эксплуатировалась база некоторые команды могут сообщить, что они ничего полезного не сделали.

sudo apt-get —purge remove pgadmin3
sudo apt-get —purge remove postgresql\*

sudo rm -r /etc/postgresql/
sudo rm -r /etc/postgresql-common/
sudo rm -r /var/lib/postgresql/
sudo userdel -r postgres
sudo groupdel postgres

2 Ноя 2017 10:11:39 | 0 comments

Полное удаление PostgreSQL 10 на Debian 9

В предыдущей статье мы установили PostgreSQL 10 на Debian 9. А если нам хочется полностью и со всеми хвостами удалить PostgreSQL 10, то как это правильно сделать?

Исходные данные: Debian 9.1 Stretch (amd64) + PostgreSQL 10

ВНИМАНИЕ! При удалении будут безвозвратно удалены все настройки и существующие базы!

service postgresql stop

Проверяем факт остановки Pg10:

netstat -ltupn | grep postgre

Удаляем Pg10 вместе со всему настройками и базами:

apt-get remove postgresql-10 postgresql-common postgresql-client-common postgresql-client-10 --purge apt autoremove -y apt-get remove pgdg-keyring --purge rm -f /etc/apt/sources.list.d/pgdg.list rm -rf /var/lib/postgresql

На этом все, до скорых встреч. Если у Вас возникли вопросы или Вы хотите чтобы я помог Вам, то Вы всегда можете связаться со мной разными доступными способами.

How To Completely Uninstall PostgreSQL

If you’re using PostgreSQL, you may need to remove the package from your system at some point. It’s important to know how to uninstall PostgreSQL properly to make sure all components of the package are completely removed and you don’t encounter any errors. In this article, we’ll explain how to uninstall PostgreSQL from Linux, macOS and Windows operating systems.

NOTE: Be sure to elevate the privileges for any of the commands in this article with sudo if the terminal returns a Permission denied error.

Uninstall and remove PostgreSQL on Debian Linux

You can use the apt-get command to completely remove PostgreSQL on a Debian-based distribution of Linux such as Linux Mint or Ubuntu:

sudo apt-get —purge remove postgresql
sudo apt-get purge postgresql *
sudo apt-get —purge remove postgresql postgresql-doc postgresql-common

Grep for all PostgreSQL packages in Debian Linux

You can use the dpkg command for managing Debian packages, in conjunction with grep , to search for all the package names installed that contain the sub-string postgres . An example of this command is shown below:

dpkg -l | grep postgres

Finally, make sure to use the APT-GET repository’s —purge remove command, followed by the postgres package name. This command will remove the package and purge all the data associated with it:

sudo apt-get —purge remove { POSTGRESS-PACKAGE NAME }

Remove all of the PostgreSQL data and directories

Use the rm command with the -rf options to recursively remove all of the directories and data for the postgresql packages:

sudo rm -rf / var / lib / postgresql /
sudo rm -rf / var / log / postgresql /
sudo rm -rf / etc / postgresql /

Screenshot of a Debian Ubuntu terminal uninstalling, removing, and purging postgresql

After you complete your rm commands, execute the dpkg -l | grep postgres command one more time to verify that all of the packages have been removed.

Uninstall and remove PostgreSQL packages on Fedora Linux

You can use the YUM repository’s yum command to uninstall PostgreSQL on Fedora-based distributions of Linux such Red Hat or CentOS:

yum remove postgresql

To use a wildcard operator ( * ) to remove all packages with names beginning with postgres , use the following command:

yum remove postgres\ *

Be sure to remove the pgsql directory as well:

rm / var / lib / pgsql

NOTE: Keep in mind that sudo is not enabled for RHEL users by default. Instead, use the su (switch user) command to enter as root and execute the above commands with elevated privileges if necessary.

Grep for the PostgreSQL packages in Fedora using ‘rpm’

You can use the rpm command with the -qa options to grep for any packages that contain “postgres” in their name:

rpm -qa | grep postgres

If you prefer, you can shorten the search to something like post as well:

rpm -qa | grep post

Screenshot of Fedora Linux using grep to look for PostgreSQL packages

You can also use grep in conjunction with YUM’s list command to return a list of all package instances of PostgreSQL:

yum list installed | grep postgres

Uninstall the PostgreSQL package using YUM remove

Once you’ve located the package, use YUM’s remove command to uninstall PostgreSQL from your Linux system:

yum remove { POSTGRESS-PACKAGE NAME }

Navigate to the assigned directory for the PostgreSQL data, and then use the rm command to delete all of your databases and tables.

Uninstall and remove PostgreSQL from Windows

If you’re using Windows, type uninstall or remove into the search bar at the bottom left-hand side of the screen:

Screenshot of Windows 10 removing the PostgreSQL application in settings

Then, follow the steps for the removal process, making sure to select the “Entire Components option when prompted.

You’ll see a pop-up stating something like: The data directory s(C:\Program Files\PostgreSQL\11\data) has not been removed . Simply click “OK” to close the pop-up window, and do not select the option to restart your PC.

Delete the data folder for PostgreSQL in Windows

After you’ve completed the removal process described in the previous section, open File Explorer for Windows and navigate to the data folder. Right-click the data folder and click the Delete button. Be sure to empty the recycle bin afterwards to ensure that any sensitive data has been properly deleted.

Screenshot of File Explorer in Windows 10 deleting the PostgreSQL 11 data folder

After all of the data has been deleted, you should restart Windows 10.

Uninstall and remove PostgreSQL on macOS

To uninstall PostgreSQL on macOS, open a new instance of Finder and navigate to the Applications directory. Look for the PostgreSQL folder and drag its contents to the Trash application folder in macOS.

Screenshot of Finder in macOS placing PostgreSQL application in trash

Remove the PostgreSQL data in a terminal in macOS

After you’ve removed the PostgreSQL folder, open the Utilities folder in a Finder window, and then open the Terminal application.

Screenshot of the Utilities folder and the Terminal application in macOS

Use the cd command to navigate to the PostgreSQL directory. You can do this by typing the directory path into the terminal prompt and pressing Return:

cd / Library / PostgreSQL / 11

Then, use the rm -rf command to remove the directory and its contents:

sudo rm -rf

Don’t forget to empty the Trash application’s contents when you are finished.

Uninstall the Homebrew installation of PostgreSQL on macOS

You can use the brew command in a macOS terminal window to remove the Homebrew version of PostgreSQL. First, use the list command to return all of the applications installed using Homebrew:

Then, use the following command to force the removal the Homebrew installation of postgresql :

brew uninstall —force postgresql

Conclusion

If you find yourself needing to uninstall PostgreSQL, it’s important to do a careful and thorough job. Taking shortcuts when it comes to the removal process can leave sensitive data remaining on your machine. In this article, we explained how to uninstall and remove PostgreSQL from Windows, Linux and macOS. With the step-by-step instructions detailed in this tutorial, you’ll be ready to remove PostgreSQL from any of your own machines.

Pilot the ObjectRocket Platform Free!

Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.

Related Topics:

  • PostgreSQL View
  • Using the CEILING Function in PostgreSQL
  • Using the Postgres BETWEEN SQL Operator
  • Array Function in PostgreSQL

Как удалить postgresql linux

PostgreSQL is among the most popular open-source relational databases that provide a wide range of advantages, including security, stability, extensibility, etc. Users can safely store vast amount of complex data using Postgres. However, when PostgreSQL is no longer needed, you can uninstall it from your Ubuntu operating system.

This blog post will demonstrate how to uninstall Postgres completely from the ubuntu operating system. So, let’s get started!

How to Uninstall Postgres From Ubuntu?

PostgreSQL may need to be uninstalled from a system at some point for various reasons, such as cleaning up the disk space, not needing it anymore, etc. So it’s crucial to understand how to uninstall the PostgreSQL database completely(along with its dependent packages) from your system.

Uninstalling Postgres from Ubuntu can be done using various ways. In this write-up, we are going to discuss a couple of them!

Contact us today for all your Postgres and Open Source consulting and support needs.

Method 1: Using ‘sudo apt remove postgresql’

This section describes the simplest way of uninstalling Postgres from ubuntu. For that purpose, follow the steps provided below:

Step 1: Uninstall Postgres

To uninstall Postgres from your Ubuntu operating system, open the terminal and run the command below:

sudo apt remove postgresql postgresql-contrib

img

The above snippet demonstrates that Postgres has been removed from Ubuntu.

Step 2: Uninstall Dependent Packages

Some additional(dependent) packages are automatically installed on Ubuntu when you install Postgres. However, when you remove Postgres from ubuntu, these dependent/additional packages are no longer needed. So, to uninstall these dependent packages, the below-mentioned command is used in ubuntu:

sudo apt autoremove

img

Type “y” and hit the “Enter” button to remove Postgres from Ubuntu:

img

The whole process will take some time to remove Postgres and its dependent packages completely from ubuntu.

Method 2: Using ‘purge remove postgresql’

If the above method is not working for some reasons, then nothing to worry about! We have explained another very convenient method to uninstall Postgres from your Ubuntu operating system.

Step 1: List Postgres Packages

Run the below-provided command to see the list of Postgres packages currently installed on your ubuntu operating system:

dpkg -l |grep postgres;

img

The above snippet shows the list of Postgres packages installed on our machine.

Step 2: Uninstall Postgres

Remove Postgres from your system by running the remove purge command followed by the name of all the packages related to Postgres:

sudo apt-get –purge remove postgresql postgresql-14 postgresql-client-common postgresql-common postgresql-contrib

img

Type “y” and hit the “Enter” button to continue the uninstallation process of Postgres:

img

The following window will appear during the uninstallation, asking you to remove Postgres directories when the package is purged:

img

Hit the “Yes” button, and it will take a few minutes to complete the uninstallation.

Step 3: Verify Uninstallation

Let’s execute the below statement one more time to verify the uninstallation of Postgres from ubuntu:

dpkg -l | grep postgres

img

The above snippet proves that postgres has been uninstalled completely from Ubuntu.

That’s all from this Postgres guide!

To uninstall Postgres from your Ubuntu operating system, open the terminal and run the “sudo apt remove postgresql postgresql-contrib” command. To uninstall the dependent packages from the ubuntu operating system, use the “sudo apt autoremove” command. Another way of removing postgres from ubuntu is by using the “sudo apt-get –purge remove” command followed by the name of packages to be removed. Through practical demonstration, this Postgres blog has explained how to uninstall PostgreSQL from the ubuntu operating system.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *