phpMyadmin database import error #1046 - No database selected

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 

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.


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


I've had this problem just this moment and none of the above answers solved my problem. Eventually, I ran the export again and the resulting .sql file was much larger. So the problem was a faulty export which resulted in an incomplete SQL file. The necessary statements would have been truncated in this case.


Need Your Help

Yii - How to get a values array from an Active Record

arrays activerecord yii

Using Yii, how can I get an array from an Active Record.

What's the best way to trim std::string?

c++ trim stdstring

I'm currently using the following code to right-trim all the std::strings in my programs: