Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jameson Cook
Jameson Cook
496 Points

Clearing database tables for reinstall

I've had a Wordpress site for a time but neglected it, and am just now learning Wordpress. I'm trying to manually install the latest updated version of Wordpress but have reached a page that tells me this:

"To reinstall please clear your old database tables first."

Please advise how to do this, and/or where I can find my next steps.

Hello, Jameson.

The quickest way to get you up and running would be to modify your wp-config.php file. This will be a simple change of a text file rather than executing SQL in MySQL. The following steps will leave your old tables in place but add new ones for your new WordPress installation. Later, once you're all set up, it will be easier to go in and delete the unused tables.

  1. Open wp-config.php (which is in your new WordPress installation's main directory) in a text editor.
  2. Locate the line that reads $table_prefix = 'wp_';
  3. Modify the value of $table_prefix so that it reads something different like: $table_prefix = 'wp2_';
  4. Save.
  5. Refresh the setup page of your WordPress installation.
Jameson Cook
Jameson Cook
496 Points

Now, I have multiple domains and multiple databases (and I don't know if some of my other domains have data stored on the same database as the one I need to "clear"), but I need to be 100% certain that this answer does not put any of my other domains' data on the database (or other databases) at risk.

Yes, this method will ensure that any previous data currently in your MySQL database does not get cleared or overwritten with the new WordPress installation. The most important thing will be to use a table prefix that is not currently being used. If you have a way to view the table names (e.g. phpMyAdmin) then that will be the definitive way to ensure you are selecting a unique table prefix. Otherwise, if you can't verify what other prefixes are being used, you can use a prefix that is extremely unlikely to have been used previously. Something that incorporates the current date perhaps: $table_prefix = 'wp20130716_';

Jameson Cook
Jameson Cook
496 Points

I made the changes you suggested to my wp-config file, and sent the revised file through my FTP software, but when I refresh my webpage, I'm receiving an Internal Server Error.

Make sure that your modifications are made inside the single quotes on that line and that the line ends with a semicolon.

$table_prefix = 'wp20130716_';
Jameson Cook
Jameson Cook
496 Points

That is all correct. Still receiving an error. I reviewed the wp-config.php file from my download folder, from the Remote Site list in Filezilla, and from the File Manager in cPanel, and they all look identical and correct.

When you navigate to <yourdomain.com>/wp-admin/install.php what do you see?

2 Answers

Courey Wong
Courey Wong
14,445 Points

this was a great solution thanks

Open up a new terminal and login to mysql and then type "show databases;" make a note of all your databases and then go back to your config files and make sure that your individual site's config file points to the correct database.

Jameson Cook
Jameson Cook
496 Points

This has not been a problem.