Debug School

rakesh kumar
rakesh kumar

Posted on

mysql:Error 1046 No database Selected, how to resolve?

error-1046-no-database-selected-how-to-resolve
error-1046-no-database-selected-how-to-resolve

Error SQL query:

--

-- Database: work


--

-- Table structure for table administrators

CREATE TABLE IF NOT EXISTS administrators (

user_id varchar( 30 ) NOT NULL ,
password varchar( 30 ) NOT NULL ) ENGINE = InnoDB DEFAULT CHARSET = latin1;
MySQL said:

#1046 - No database selected
Enter fullscreen mode Exit fullscreen mode

Image description

Solution
You need to tell MySQL which database to use:

USE database_name;
before you create a table.

In case the database does not exist, you need to create it as:

CREATE DATABASE database_name;
followed by:

USE database_name;
Enter fullscreen mode Exit fullscreen mode

Image description

Top comments (0)