Fix SQL Error 1046

SQL Error 1046 is usually triggered when the database to be used is not selected.

In this context, we will look into the causes of this error and how to go about fixing it.

Main Causes of SQL error 1046

As earlier stated, the main reason why the error comes up is when a database is not selected as we do regular activities such as creating a table or restoring tables from a recent backup.

For instance, in a situation when we wish to create a particular table, and do not use the actual name of database then we tend to get this error! This is as a result of not choosing the database. 

Method to solve SQL error 1046

Now we will see how our Server Experts fixed this issue in different scenarios.

i. Recently, a client consulted us regarding fixing this error message in the process of creating a table.

We analyzed his situation and discovered that the database was not selected while creating a table.

Therefore, we used the command below to select the database;

USE name_of_database;

In the case where the database does not exist, we then create the database via the command below;

CREATE DATABASE name_of_database;

Now this fixed the Error.

ii. In a similar case, we encourage our client to import the database via the phpMyAdmin portal in their server if they have the database file they got through a recent backup. The following steps can be taken to do it;

* To begin, we log into the phpMyAdmin. Create a database from within and select the database from the left panel of the page.

* Then we simply click on the import option which is located at the top bar of the page.

* In the import page, click on "Browse" button located close to the Location of the SQL file.

* From here you will browse to the location where you saved the database file in your local computer and select it.

* Finally, click on the "Go" button and the database will be imported shortly.

Need support in solving SQL errors? Consult us today.


Here at IbmiMedia, We continue to see rising cases of clients seeking support on how to solve SQL related errors as part of our Linux Support Services. This error happens when a database is not selected correctly.