Error 1046 no database selected sql statement

error 1046 no database selected sql statement

A bug in mysql Workbench: Error Code: No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS. mysql – phpMyadmin database import error # – No database selected The error is because you either didnt select a database on the left side. sql – Error No database Selected, how to resolve? · 1- Create new database · 2- Use it by use command. enter · 3- Try again.

You can watch a thematic video

MySql Workbench Error 1046- No Database Selected mybusiness         Database           test            

MySQL Error - # - No database selected

The error-# can occur when we are creating a table, but forget to select the database. Let us say we have started MySQL as shown below −

Command Line

After giving the correct password, the above window will open. Now create a table without choosing any database. This will show an error −

mysql> CREATE table TblUni -> ( -> id int, -> Name varchar() -> );

ERROR (3D): No database selected

The following screenshot is showing the same error −


Now, choose any database to get rid of the above error. Firstly, let us check how many databases are present in MySQL with the help of SHOW command −

mysql> SHOW databases;

The following is the output −

++ hello              

This article is a step-by-step guide to resolve the “MySQL ERROR (3D) No Database Selected” error. If you are a DBA or a developer, this post will help you fix this MySQL error.

If you are getting this error message means you are trying to execute MySQL queries statement using the MySQL command prompt, error 1046 no database selected sql statement. Let’s go through why we get the error (3D) followed by the step-by-step procedure to resolve this error.

Why you are getting MySQL Error (3D) No database selected?

MySQL ERROR (3D) No Database Selected

Let me tell you first why you are getting this MySQL error message.  You might have guessed it right by now; the error message error 1046 no database selected sql statement pretty clear that you have not selected the database before executing your MySQL statement.

This error generally occurs when you try to create a Table in the MySQL database using the command prompt.

Because while executing a command from the command prompt you need to select the database also error 1046 no database selected sql statement MySQL will not be able to know for which database you are executing the script.

When you execute create table statement from MySQL workbench then at that time you need to manually xampp error establishing a database connection wordpress the database then you execute your statement. Similarly, while executing a script from the command prompt screen, make sure you have provided the database name.

The next question is “how to provide the database name?” No worries. Here are the steps; just follow the below steps by step procedure to get rid of the error.

Steps to resolve MySQL ERROR (3D) No Database Selected:

Step 1:

  • Open MySQL command prompt.
  • Go to the start menu and open MySQL Command Line Client.
MySQL command line client

Step 2: Select the database

If you know the database name:

  • Select the Database on which you want to execute your script.
  • If you know the name of the database, then enter the database name in the following format.
select and use a database in MySQL

Note: Don’t skip this step, this is the solution to get rid of the (3D) error message.

If you do not know the database name:

If you don’t know the available database names or the database on which you are going to execute the script, then you can list all available databases using the following command.

Show database command lists down all the databases available. Then you run use <database_name>;

Show database in MySQL

Step 3: Execute statement

Once the database is selected, you can execute your required SQL statement. Here we will execute create table statement in the database as an example.

mysql create table no database selected fix - table created

That’s it. You can see the created table in the MySQL database using MySQL workbench.

Table created in MySQL


Is it not simple? I hope you now know the reason behind the “MySQL error No Database selected error” issue and how to fix it. Do share your feedback if this post helped you to fix the MySQL (3D) error using the above steps in the comment section.

Cheers !!!

Similar article:
1. Fix “unknown collation ‘utf8mb4_unicode__ci’” Error

Apologise: Error 1046 no database selected sql statement

Error 1046 no database selected sql statement
error 1046 no database selected sql statement


  1. Excuse for that I interfere � here recently. But this theme is very close to me. Is ready to help.

Leave a Comment