Delete WordPress installation

Sometimes you end up to situation that you need to delete the WordPress site completely. If you website is in hosted environment they usually have means to delete the whole installation. In this case we have our own virtual server and we need root access to the server.

This article tell you how to delete WordPress website completely. Your installation includes following things:

  1. Domain definitions
  2. Installation files
  3. The database

Backup

Backup all your databases with following command:

backupfile=full-backup-$(date +%F).sql; mysqldump --all-databases --single-transaction --quick --lock-tables=false > $backupfile ; gzip $backupfile

Delete the Database

Lets start from the bottom. Delete the database. First we need to know the name of the database.

cd /directory-of-you-wp-installation

grep DB_NAME wp-config.php

Or just the name:

grep DB_NAME wp-config.php | tr \’ ” ” | awk ‘{print $4}’

That should output the database name.

Then as root open the database server connection.

mysql

drop database <databasename> ;

<ctrl>-<d> to exit

if you try from command line: mysql <databasename> if should work any more.

Quick version:

cd /installation directory
DDB2DEL=grep DB_NAME wp-config.php | tr \' " " | awk '{print $4}' ; echo "Database to delete: " $DB2DEL
mysqladmin -u root drop $DB2DEL

Delete the installation

As user or root delete your installation directory:

rm -r /directory-of-you-wp-installation

Remove Domain definition

You need to delete the domain from your server definitions and remove it from the DNS.