While WordPress provides easy way in dashboard updates page to reinstall WordPress. But there are some cases when you need to know different ways to reinstall WordPress. The reason can be anything like your website have gone infected or broken. Or you are jus doing it for some learning or testing purposes. As you know your WordPress themes, plugins and uploads are all inside wp-content directory. So never delete wp-content directory otherwise you will lose everything. The second most important file is wp-config.php which have your database connection information so do not delete this file as well.
In this tutorial we are going to guide you through 4 different ways to reinstall WordPress. We are also going to guide you through installing a completely new WordPress and importing the current content there.
When do you have to reinstall WordPress?
There can be many reasons that you have to reinstall WordPress. Most common reasons are a Hack attack, malware or broken WordPress files. Sometime WordPress is unable to complete its core files update and that breaks the website. And if a malware have been installed on your website somehow that will infect all your WordPress directories and files. In these type of situations rather than you find out the broken or missing files. The best way is to reinstall WordPress to make sure everything is good.
Whenever you remove a malware do not forget to close the backdoor which let that malware enter into your site. Its also an important part of WordPress troubleshooting to reinstall WordPress core files. So whatever is the reason you have to reinstall WordPress let’s do that.
Precautions before you reinstall WordPress
While we have listed below around 4 different ways to reinstall WordPress. But before you start reinstalling your WordPress with anyway. It is highly recommended that you take the backup of your WordPress important directories, files and database before doing this.
- Take backup of your wp-content directory
- Download and save wp-config.php file somewhere
- Take backup of your WordPress database by phpMyAdmin
If something goes wrong you may start facing There has been a critical error on this website.
How to reinstall WordPress?
Here I assume that you have already taken backup of your WordPress website. In simple words to reinstall WordPress you would just need to replace wp-admin directory, wp-includes directory and all other WordPress files except wp-config.php and wp-content directory.
Download the latest WordPress and extract it delete wp-content directory from it so it do not replace your original wp-content on server.
1. Reinstall WordPress via WordPress Admin Dashboard
If WordPress admin panel is working and you are able to access the dashboard. Then its peace of cake to reinstall WordPress with only a click on button. To reinstall WordPress from WordPress admin panel sign in your WordPress admin panel go to updates page and reinstall.
- Sign in WordPress admin
- Under dashboard menu in sidebar open Updates page
- Click Re-Install Version x.x button
Done you have reinstalled WordPress via WordPress admin panel.
2. Reinstall WordPress via FTP
Well as you know the rule to reinstall WordPress. You do not have to delete wp-content directory and wp-config.php file. Other than that you can delete all WordPress related directories and files as shown in video below to reinstall WordPress via FTP. Make sure you have taken the backup of your WordPress website before doing this.
So what do you need to reinstall WordPress via FTP. You just need access to your website via FTP for this you need FTP host, Username and password. So you can connect your FTP client with your web server. If you don’t know these credentials you may contact web hosting support.
- Connect your website via FTP using a FTP client.
- Delete everything including wp-content, wp-includes and all other files.
- Do not delete wp-content as it have themes, uploads and plugins
- Do not delete wp-config.php as it have your database connection information
- Download latest version of WordPress extract in local directory
- Upload everything except wp-content
Once upload is complete you have successfully reinstalled WordPress via FTP.
3. Reinstall WordPress via cPanel File Manager
To reinstall WordPress via cPanel File Manager. You would need to have access to cPanel of website which you are going to reinstall WordPress for. Its also recommended to take backup of your website before doing anything. We have also created a video to reinstall WordPress via cPanel watch below.
There are few steps which you have to take after you are loged in to your cPanel account. Just open the File Manager and go to your WordPress installation directory either its public_html or any other directory where you have to reinstall WordPress.
- Login your cPanel account and open File Manager from Files section
- Open your WordPress installation folder
- Select all except wp-content and wp-config.php file
- Delete everything you have selected
- Download latest version of WordPress
- Upload the downloaded zip file and extract
- The extracted files are inside wordpress directory enter in it
- Move everything to your WordPress installation except wp-content
That’s it you have successfully reinstalled WordPress via cPanel file manager.
4. How to reinstall WordPress using WP-CLI?
There is also a command line using WP-CLI to reinstall WordPress except content directory. The WP-CLI is command line tool which helps you perform certain WordPress functions. You can use WP-CLI to reinstall core WordPress directories and files. While you can add or remove users, manage categories and posts, insert test data and replace or modify database with WP-CLI. You should be assure on what you are doing to avoid any problem. The command below can be use in WP-CLI to reinstall your WordPress core files and directories.
wp core download --skip-content --force
How to completely reinstall WordPress (Deleting All Files)
If you believe that something is wrong with your database. But you are not sure how to clean or optimize the database. Maybe for some reason your postmeta table have grown so huge that its slowing down the website. Or a bad SQL injection have produced various infected rows into your database tables. The best way is to reinstall WordPress completely on a new database.
This way you would have completely fresh WordPress installation with same old wp-content folder. And any bad rows or tables which exists in your database table would not be infected.
Please note: All your WordPress settings like theme options, menus, customizer options would not be recoverable this way. You would have to redo them. So make sure you do not have highly customized website. Or you may hire a WordPress expert.
1. Export WordPress XML File
Login your WordPress admin panel and go to dashboard > Tools > Export. Select All content radio button and download your WordPress exported XML file into your computer. This file have your posts, pages, custom post types, comments, authors and everything.
2. Download WordPress wp-content directory
Now connect your web server via FTP or File Manager cPanel and download wp-content directory in your computer.
This is important to download and save your wp-content directory as it includes your plugins, themes and uploads.
3. Delete everything from your server
Now login your server via FTP or File Manager and delete everything once you have downloaded exported XML file and wp-content directory. Now you should have an empty directory of your WordPress installation.
Important: Before doing this make sure you have backup of your website and also you are in right WordPress installation directory. If you have more than one WordPress installations then there can be chance you delete wrong site.
4. Delete database and maybe its user
Now either delete your database or just leave it as it is in case you want to use it as backup. Your WordPress installer will install the create a new database however. So i don’t recommend doing this if you have more than 1 database allowed on your server. In case you want to delete database just go to databases section and delete your WordPress database.
5. Install a new WordPress going to WordPress toolkit
There are various ways you can install a new WordPress but here we will only show you via WordPress toolkit in cPanel. Your Control panel can have different WordPress installer but all do the same work.
- Go to WordPress toolkit
- Click on Install
- Enter website name if have more than 1 websites on same server
- Enter directory name leave blank to install in domain’s root
- Click install filling all other required fields
That’s it now you have installed WordPress and now you can login your WordPress admin panel of fresh installed WordPress.
6. Reupload wp-content directory to new installation
Now connect your website using FTP and upload wp-content directory in your freshly installed WordPress. Once you have uploaded wp-content your newly installed WordPress will have all your plugins, themes and uploads available to use.
Remember the directory you are uploading wp-content should be the same which you downloaded in step 2.
7. Important: Activate the plugins and themes your site was using before
As you know you have installed a fresh WordPress with a new database. So if your theme had created some database tables or any of the plugin you were using created a database table that would not be available at this stage. So activate your theme and all plugins your site was using before. They will create their required tables, and will put required data into database for them.
This is important to do this before importing XML file cause some plugins have custom post types as well as themes. So those custom post types have to be available before you run import to import their data as well.
8. Import your downloaded XML file
Now you can go to WordPress dashboard >> Tools >> Import and click WordPress to import the XML file you exported and downloaded in step 1. Remember this import would only create posts, pages, menus and wouldn’t download any media files cause you already uploaded them in wp-content via FTP.
This import would also not set your theme functions or customizer options and other plugins, themes settings. This import would also not set your widgets. These things you would have to do yourself again.
Done you have now successfully completely reinstalled your WordPress. This have given you a fresh new database on new installation but the wp-content is still old.
Hire a WordPress developer to reinstall WordPress
We can be great in something but being Jack of all trades is not always good idea when its something related to your online business, reputation or brand. The wise decision can be to contact an expert of that business to get the right solution. So if you believe you need correct WordPress reinstall then you should hire a WordPress developer to reinstall your WordPress in correct way. And get everything sorted out the right way.
WordPress release continuous updates to their core files cause of security fixes, new feature addition or improvement in existing features. While you can easily update WordPress from dashboard but sometime certain things happen like server goes unresponsive. These type of issues can break your WordPress core files and you may need to reinstall WordPress in such cases. While WordPress have been broken or is not working then the manual reinstall is the only solution.
The other case can be a malware or hacker’s attack on your website. Which can put up some infected files on your website. Or put malicious code in your existing WordPress files. In such cases when you detect a malware on your website the best way to fix is reinstall WordPress. And carefully analyze your wp-content directory. If your website have been hacked and there is some malicious code or output you may need the help of a WordPress developer. Who can clean up your website completely otherwise malware can bring the infected files back again and again. Some of common known hack or malware warnings with details to fix are listed below.
You may find some other similar articles useful.
- WordPress Hacked Redirects To Other Websites Redirect Malware
- How To Fix “The Site Ahead Contains Malware” Error On WordPress
- “This Site May Be Hacked” Message
- How To Remove ‘Deceptive Site Ahead’ Warning?
So either your website have been hacked or the files have been broken cause of failed WordPress update. In either case a hiring a WordPress developer can be a wise decision.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?