Fix a Broken Drupal Database Table

fix drupal database table

One OSTraining member told us that they had a database error on their site.

Here’s the error that was showing:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘cache_rules’ doesn’t exist

Fortunately, a solution was provided on the Drupal forums. However, the solution was an update to the database, and our member wanted some advice on how to run that update.

In this tutorial, we’ll show you a non-technical way to run an update on your Drupal database.

Before we start, here’s the solution we’re going to implement.

Step 1. Use a test site or create a backup

Please make sure you run your update on a test site first.

If you absolutely can’t do that, take a database backup first. Our class on the Backup and Migrate module will show you how.

There are no un-do buttons for database updates.

Step 2. Access your databases

First, you need to access the databases for your hosting. In this example, we’ll use phpMyAdmin. Here’s what the phpMyAdmin looks like inside many hosting accounts:

media_1410801885347.png

Step 3. Find your database

Make sure that you find the database your site is using. Most hosting set-ups will have at least 2 databases, so make sure you edit the right one.

If you’re unsure which database you’re using, check the settings.php file for your Drupal site.

media_1410802829819.png

Step 4. Access the SQL query area

In phpMyAdmin, click on the SQL link. This is where you can apply your database updates:

media_1410801937204.png
 
 

Step 5. Prepare the update

Most of the time, database updates are given with a default database prefix. In this example, that prefix is XX_.

We need to replace that with our database prefix, which in this case is xtv_.

So the first part of my update will look like this:

DROP TABLE xtv_cache_rules ;
CREATE TABLE IF NOT EXISTS `xtv_cache_rules`
media_1410802108444.png

Step 6. Run the update

You can enter your database query into the SQL field and click the “Go” button:

media_1410802030634.png

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x