WordPress Reinstallation Guide
This guide covers two methods to reinstall WordPress while preserving the database and essential configurations.
🔹 Method 1: Manual Re-installation
This method manually downloads and replaces WordPress files.
1️. Access the WordPress Directory
Find the database name from the `wp-config.php` file:
cat wp-config.php | grep DB
2️. Backup the WordPress Database
Dump the WordPress database :
mysqldump -u username -p DBname > database.sql OR mysqldump DBname > database.sql
3️. Backup All Files
tar -czvf fullbackup.tar.gz *
4️. Check Current WordPress Version
cat wp-includes/version.php
If you need to reinstall the same version, download it from:
🔗 WordPress Releases
5️. Download and Extract WordPress
wget https://en-ca.wordpress.org/wordpress-6.2.1-en_CA.tar.gz or wget https://panelwebhosting.org/script/wp/vs/wordpress-*.tar.gz
tar -xvf wordpress-6.2.1-en_CA.tar.gz
6️. Remove New WordPress wp-content Files
cd wordpress/ rm -rf wp-content
7. Remove Old WordPress Core Files
Navigate to the `public_html` directory:
cd ..
8.Remove default WordPress core files (keeping custom content safe):
rm -rf xmlrpc.php wp-trackback.php wp-signup.php wp-settings.php wp-mail.php wp-login.php wp-load.php wp-links-opml.php wp-includes/ wp-cron.php wp-config-sample.php wp-comments-post.php wp-blog-header.php wp-admin/ wp-activate.php readme.html license.txt index.php
9. Move New WordPress core Files to the Website Directory
cd wordpress/ mv * ../
10. Set Correct Permissions
chown -R username:group * chown -R username. *
✅ Done! WordPress has been reinstalled manually.
🔹 Method 2: Using WP-CLI
This method uses WP-CLI (if installed on the server).
1️. Find the database name from the `wp-config.php` file:
cat wp-config.php | grep DB
2. Dump the WordPress database :
mysqldump -u username -p DBname > database.sql OR mysqldump DBname > database.sql
3️. Backup All Files
tar -czvf fullbackup.tar.gz *
4. Check WordPress Version
cat wp-includes/version.php
5. Remove Old WordPress Core Files
rm -rf xmlrpc.php wp-trackback.php wp-signup.php wp-settings.php wp-mail.php wp-login.php wp-load.php wp-links-opml.php wp-includes/ wp-cron.php wp-config-sample.php wp-comments-post.php wp-blog-header.php wp-admin/ wp-activate.php readme.html license.txt index.php
6. Download and Install WordPress core files Using WP-CLI
wp core download --version=6.0.2 or wp core download --version=6.0.2 --allow-root
7. Set Correct Permissions
chown -R username:group * chown -R username. *
✅ Done! WordPress has been reinstalled using WP-CLI.🚀