Import error - MySQL said: #1046 - No database selected
Posted by: IrvC (---.hfc.comcastbusiness.net)
Date: February 21, 2014 04:27PM

I am trying to import the database that I exported from our live site to WAMP using phpMyAdmin. I browse for the .sql file that the export created and click GO. I tried leaving SQL compatibility mode as NONE, and also selected MYSQL40 and MYSQL323 for compatbility mode.

I am getting error #1046 - No Database Selected.

Any clues?

Irv

Windows 7
WAMP ver. 2.4 (just downloaded this week)



Edited 1 time(s). Last edit at 02/21/2014 04:46PM by IrvC.

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: RiggsFolly (---.as13285.net)
Date: February 23, 2014 03:43PM

Look at your .sql file from your database dump. It probably does not contain a 'USE xxx;' statement.

So add a

USE databasename;

To the top of your .sql file where 'databasename' is a database you have previously created using phpmyadmin.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: IrvC (---.hfc.comcastbusiness.net)
Date: February 24, 2014 09:31PM

thank you for your reply.

I have a couple related questions:

1) when I first launched phpMyadmin in WAMP I was prompted for a username and password. I entered the username for my live site database, which I guess was the wrong thing to do. I can launch phpMyadmin using this username and leaving the password blank. Should I have created a new username and password? Where would I do that?

2) I had not initially created a database in WAMP before trying to import, so per your suggestion above I clicked the Databases tab but below the Create Database link it says No Privileges. The download instructions said everything is set up automatically, but it would seem I need to do something to set up my credentials. But how?

thanks,

Irv

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: RiggsFolly (---.as13285.net)
Date: February 25, 2014 01:44AM

1) MySQL comes with 1 userid pre configured ... Username = root, Password = (leave this blank )

2) If you login with an actual existing userid ( as above ) then you will get the privileges for that userid ( root is the Super User and can do anything )


please see the bottom of this port for a link to the MySQL documentation.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: IrvC (---.hsd1.il.comcast.net)
Date: February 25, 2014 07:12PM

Ok I created the database in phpMyAdmin and started the import but it timed out before completing.

Then I went to the MySQL console and used the source command, which got much further but it timed out after 300 seconds before completing. Can I change the 300 second maximum execution time?

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: RiggsFolly (---.as13285.net)
Date: February 25, 2014 11:07PM

There is no timeout if you are using the MySQL Console.

It runs and runs until it completes the restore script, unless there is something wrong with the script.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: IrvC (---.hsd1.il.comcast.net)
Date: February 26, 2014 12:35AM

First I issued the command:

use <database.name>

then the command:

source <path\filename.sql;

so I don't know how there could be an error in the script, but it did respond after a while:

ERROR 1064 (42000): You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '<br />
<b>Fatal error</b>: Maximum execution time of 300 seconds exceeded in <b' at line 93

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: RiggsFolly (---.as13285.net)
Date: February 26, 2014 01:46AM

There should not be a '<br />' in a database dump. Are you sure that the filename.sql was created by a datbase dump?

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: IrvC (---.hfc.comcastbusiness.net)
Date: February 26, 2014 04:12PM

yes the file was created by using the Export feature of phpMyAdmin on the host for our live site.

Looks like I need to scrub the data and re-export??

Options: ReplyQuote
Re: Import error - MySQL said: #1046 - No database selected
Posted by: IrvC (---.hfc.comcastbusiness.net)
Date: February 27, 2014 06:14PM

I finally found an editor that could open a file of this size and see that it was the export that died, not the import. The error message I reported earlier is at the end of the export file and is not being generated by the import after all.

thanks for your help on this. I assume that my host can resolve the export timeout problem and I will be all set.

Options: ReplyQuote


Sorry, only registered users may post in this forum.