phpMyadmin database import error #1046 - No database selected

67,045

Solution 1

The error is because you either didn't select a database on the left side to import to, and/or you didn't create the empty database first. Create a database in phpMyAdmin called "phplogin", select it on the left side, and then run the import.

Solution 2

Append the following line to the beginning of your sql file

CREATE DATABASE phplogin;

These problems can be resolved by exporting the SQL file while being outside the database.Then phpmyadmin automatically appends the above statement to the SQL file

Share:
67,045

Related videos on Youtube

user780483
Author by

user780483

Updated on May 11, 2020

Comments

  • user780483
    user780483 almost 4 years

    I have an sql file that i exported from phpmyadmin on another computer. I tried to import the file on this computer and I get this error:

    Error
    

    SQL query:

    --
    -- Database: `phplogin`
    --
    -- --------------------------------------------------------
    --
    -- Table structure for table `people`
    --
    CREATE TABLE IF NOT EXISTS  `people` (
    
     `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
     `name` VARCHAR( 25 ) NOT NULL ,
     `age` INT( 11 ) NOT NULL ,
     `testvar` VARCHAR( 5 ) NOT NULL ,
    PRIMARY KEY (  `id` )
    ) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =3;
    
    MySQL said: 
    
    #1046 - No database selected 
    
  • Old McStopher
    Old McStopher almost 10 years
    Any idea how to do this in a phpMyAdmin configuration that only logs into a specific database? (Thus there is no DB to select on the left, only tables.)
  • Lee
    Lee about 8 years
    Also, what if there was no database to select in the first place? I made an entire export of my entire phpmyadmin collection, and reformatted my computer. When I try to import the file, I get the same message. I need it to create the database tables for me, as I can't go through and add each one exactly as it was.. Why didnt this get included in the export?