3

I'm having trouble when trying to import a database into phpmyadmin.

Error
SQL query:

--
-- Database: `iiumcms`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE IF NOT EXISTS  `admin` (

 `fname` VARCHAR( 50 ) NOT NULL ,
 `email` VARCHAR( 50 ) NOT NULL ,
 `admin_no` INT( 11 ) NOT NULL AUTO_INCREMENT ,
 `dept_id` VARCHAR( 15 ) NOT NULL ,
 `username` VARCHAR( 30 ) NOT NULL ,
 `password` VARCHAR( 30 ) NOT NULL ,
PRIMARY KEY (  `admin_no` )
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =7;

MySQL said: Documentation

#1046 - No database selected 
j08691
  • 204,283
  • 31
  • 260
  • 272
user2961517
  • 31
  • 1
  • 1
  • 2
  • 2
    Seems pretty clear, you have to select a database in phpMyAdmin. – gview Nov 07 '13 at 21:26
  • did you mean that i need to create a database name iiumcms and only after that i can import the database iiumcms? – user2961517 Nov 07 '13 at 21:29
  • yes exactly. MySQL always has to operate within the context of a selected database. – gview Nov 07 '13 at 21:30
  • possible duplicate of [Cant import phpmyadmin database](http://stackoverflow.com/questions/6880511/cant-import-phpmyadmin-database) – Shafeeque Nov 08 '13 at 04:13

4 Answers4

5

You have to create an empty database with name 'iiumcms' in your PhpMyAdmin and have to select this database in left sidebar before importing your .sql file.

Abhishek Balani
  • 3,827
  • 2
  • 24
  • 34
2

You have to first select your database, then import file.

In MySQL you can use this statement:

USE `iiumcms`;

If you don't have this database created, you have to do it first.

Elon Than
  • 9,603
  • 4
  • 27
  • 37
1

This error when o didn't tells to mysql what is the database to do the restore. You need put:

USE `your_database_name`;

at the begin of your file.

Miguel Q.
  • 567
  • 4
  • 14
0

In phpMyAdmin, this means choosing a database from the sidebar and then using its import tab. If the database you want to fill doesn't exist, you have to create it first using the Create new database form.

Sathish D
  • 4,854
  • 31
  • 44