Удаление postgresql astra linux

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:

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:

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 /

Читайте также:  Диагностика сетевой карты linux

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:

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

Be sure to remove the pgsql directory as well:

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:

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

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:

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:

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.

Читайте также:  Linux format drive ntfs

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:

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

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 :

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.

Источник

How to uninstall the postgresql

The simplest way to do this is open a terminal and type:

sudo apt-get --purge remove postgresql 

This will remove the postgresql package. There may be chances that additional packages are also installed so you can search them by typing:

and purge all those packages by sudo apt-get —purge remove .

Thanks! But still i got some left. Is there a possible way i can delete the postgresql «folder by folder»

To completely uninstall PostgreSQL

sudo apt-get purge postgres.* 

I just want to add that any packages installed using apt, apt-get or from .deb files for example, can be uninstalled using:

sudo apt-get purge package_name.* 

List package and all of its dependencies to check what are being uninstalled:

dpkg --list | grep package_name.* 

.* after package_name is very important to regex match all possible dependencies associated with a package.

Читайте также:  your_domain website

To completely remove Postgres with dependent packages, I used the following commands on my Ubuntu 20.04.

First check the postgres installed version
dpkg -l | grep postgres

Then use the following command to remove all dependencies. Use your version number.

$ sudo apt-get --purge remove postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common 

Источник

How To Remove PostgreSQL

Sometimes during a software install, things can go sideways and you realize that not all the program downloaded or the installation was interrupted for some reason leaving you with incomplete files and empty directories. Honestly, this is a rare occurrence but it can happen from time to time. This then begs the question; So how do I completely uninstall recently installed software? In this tutorial, we’ll be safely removing PostgreSQL from our Liquid Web Ubuntu VPS server.

How To Remove PostgreSQL

Step 1: List the PostgreSQL Packages

Use the dpkg tool to list packages pertaining to the PostgreSQL setup.

postgresql

Step 2: Delete the PostgreSQL Packages

In Step 1, all of the software packages related to the PostgreSQL install are shown. To remove and delete them all with one command, Start with this command.

apt-get --purge remove command

This is followed by each package name indicated separated with a space. For my particular version of PostgreSQL, the software installed was:

  • pgdg-keyring
  • postgresql-10
  • postgresql-client-10
  • postgresql-client-common
  • postgresql-common

so, my purge remove command will look like this:

sudo apt-get --purge remove pgdg-keyring postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common

Step 3: Verifying the Deletion of PostgreSQL

Once you remove these packages you should no longer be able to enter into the PostgreSQL environment. You can verify that by running the grep command again and searching for postgres:

root@newclient:~# dpkg -l | grep postgresroot@newclient:~#

As you can see, there is no output from that command which means, PostgreSQL has been successfully uninstalled!

If you have other thoughts or questions, our Sales and Support teams are standing by 24 hours a day by phone or e-mail to assist. Reach out to us by opening a support ticket at support@liquidweb.com, giving us a call at 1-800-580-4985 or, open a chat with us and we’ll be happy to answer any questions you may have!

Thank you for hosting with Liquidweb!

Источник

Оцените статью
Adblock
detector