Tuesday 19 April 2016

No database selected

ERROR 1046 (3D000): No database selected

we have two scenario
1) check if database exist.
2) if database not exist, create and use the database.

for case 1.

1) see database.
cmd :  show databases.
it will show default listing.
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec

now we have to create the DB and recheck again.

2)  if database not exist, create and use the database.
a) create database test.
cmd : create database test.
b) check test db created or not.
cmd : show databases.

+--------------------+
| Database           |
+--------------------+
| information_schema |
  test
+--------------------+
1 row in set (0.00 sec

c) start using the database.
cmd : use test.



  

No comments:

Post a Comment