Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpMyadmin database import error #1046 - No database selected

Tags:

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  
like image 994
user780483 Avatar asked Jul 30 '11 01:07

user780483


People also ask

Can import database phpMyAdmin no database selected?

If you have an SQL database file, you can also import it to PhpMyAdmin and resolve the “No Database selected” error during the SQL file import as seen below: First, ensure that you already have a new MySQL database on Live Site. After that, go to phpMyAdmin on the live site and log in to the database.


2 Answers

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.

like image 89
Clowerweb Avatar answered Oct 25 '22 15:10

Clowerweb


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

like image 30
funtime Avatar answered Oct 25 '22 15:10

funtime