Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 

need some help here.

like image 600
steph Avatar asked Oct 23 '10 18:10

steph


People also ask

How do I fix no database selected?

The error no database selected frequently occurs in MySQL when you perform a statement without selecting a database first. You need to replace [database_name] with the name of a database that exists in your MySQL server.

How do I fix error 1046?

Ensure that your PAYE reference number, Accounts office reference and HMRC office name are entered correctly and match the details that HMRC have for you. Check the references don't have 'Z' instead of '2' or '0' in place of 'O'. Ensure your email address is correct and matches the one you have registered with HMRC.


1 Answers

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; 
like image 167
codaddict Avatar answered Sep 20 '22 03:09

codaddict