In this tutorial, we will show you how to completely remove your Wordpress site on your server. We will also provide you with additional instructions of how to backup your WordPress site first if you want to do it before the uninstallation.
First, you will need to log in to your server via SSH. Then, navigate to your Wordpress Root Directory.
For example, it could be located at: /var/www/html/wordpress/.
To make a full archived backup of your whole WordPress site, you can execute the following command:
tar -cpzf wp-backup.tar.gz /var/www/html/wordpress/
This will create an archive file of all the WordPress files.
Additionally, you will also need to make a backup of your Database. Your WordPress database stores all the information about your website like posts, comments, user accounts, plugin configurations etc.
To make a full backup of your database you can use the following command, followed by your database password:
mysqldump -u db_user -p db_name > wp_database_backup.sql
Make sure change the wp-user and wp-database accordingly with your actual database user and database name.
If you are not sure of your database information that is currently connected to your WordPress site, you can check the wp-config.php file inside your WordPress root directory and look for the following lines:
define('DB_NAME', 'your-database-name'); define('DB_USER', 'your-database-user'); define('DB_PASSWORD', 'your-database-password')
You can also create a copy of your database through a control panel, like cPanel or DirectAdmin, if you have one installed on your server.
Now, you have a backup of both your website files and your database, which you can store on your server or transfer them to your local computer via FTP.
After we made a full backup of our site, we can now proceed with the uninstallation.
You can do this by simply deleting all the data in your WordPress root directory.
So, for example, if your WordPress site is located at /var/www/html/wordpress , you can remove all its contents with the following command:
rm -rf /var/www/html/wordpress/*
Next, you also need to delete the database.
To do this you can log in to mysql as root with the following:
mysql -u root -p
Once logged in, if you want to list all the databases you can type:
and then you can execute the following command to delete your WordPress database (make sure you are deleting the correct database that was specified in your wp-config file):
DROP DATABASE your-database-name;
If that is the only database assigned to this user, you can also delete the user with the following command:
DROP USER 'your-database-user'@'localhost';
To list all the users and their hosts, you can run the following:
SELECT User, Host FROM mysql.user;
Once you are done, you can exit mysql with;
As mentioned before, if you already have access to any control panel like cPanel or DirectAdmin, you can easily delete the database through the control panel itself.
Additionally, you can also delete the virtual host configuration file for your domain if you no longer plan to use it.
If you have carefully followed all the steps in this tutorial, you have now completely removed your WordPress site from your server.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.