Ad

Importing Single MySQL .sql File For ENTIRE Database | No Database Selected Error

- 1 answer

I know it's probably not the correct way to do it, but I exported my entire database to a file called localhost.sql. I don't know how to import this to my new database, because it asks for a target database to put it in, but I don't have one, I need it to import the entire database, not to a table. Or at least that's how I understand it.

When I go to PhpMyAdmin and go to import and choose that file, then click Go, it gives this error...

Error:

SQL query CREATE TABLE IF NOT EXISTS pinnums (pin varchar(5) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1

1046 - No database selected

Yes it's pretty self-explanitory, but hours of looking at forums and trying stuff that dosn't make sence/work...I don't know...

I don't think I can show my database file as it contains sensitive info.

Most of my website runs off of these databases that I can't access, so I need them or all of my work is done for. :( Any thoughts help!

Ad

Answer

Yay! I had a small hypothesis that the .sql file was text-editor-readable, and I was right, so I manually recreated all of my databases and filled them using the pre-made code in the .sql backup file. The reason for the error, is because which database the info should go in wasn't commented out for some reason.

Ad
source: stackoverflow.com
Ad