Error 1046 No database selected, how to resolve?
database, mysql, mysql-error-1046, mysqlcommand, sql
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;
Problem
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 ``` need some help here.