Guides & TutorialsTroubleshootingTroubleshooting UpdatesResolving MySQL Error Code 1146 - Base table or view not found

Resolving MySQL Error Code 1146 - Base table or view not found

Introduction

When applying an update to the WHMCS software an error stating  Base table or view not found is displayed. The full error may look like:

Unable to complete incremental updates: Unable to import the 8.0.0  Alpha1 database file.
Unable to import  /path/to/whmcs/resources/sql/upgrade800alpha1.sql:  SQLSTATE[42S02]:
Base table or view not found: 1146 Table 'table_whmcs7.tbldomainpricing_premium' doesn't exist
Click to copy

This guide demonstrates how to resolve this error.

Cause

This error occurs when a table does not exist in the WHMCS MySQL database, but the update process needs to make a change to that table.

In this example the tbldomainpricing_premium table does not exist. It should be present.

A missing table could be caused by an update failure in the past, or accidental/malicious removal of the table.

Resolution

The table identified by the error message must be re-created. Follow these steps:

1. Navigate to the /resources/sql/install/ directory

2. Identify the .schema.sql file with the filename corresponding to the missing table name. In this example that's tbldomainpricing_premium.schema.sql:

Open the .schema.sql file for the missing table

3. Edit the file to view its contents

4. Copy the SQL CREATE TABLE command shown in the file. For example:

Identify the CREATE Table command

5. Using a database administration tool such as phpmyadmin, execute the SQL command copied from the .schema.sql file. For example:

Execute the CREATE TABLE command against the WHMCS Database

6. Ensure the create query executes successfully:

Command Successful

7. You may now return to WHMCS and re-run the update process.