Importing using MySQL WorkBench... error ERROR 1046 (3D000)

70.9k views Asked by At

Scenario: building a RoR enviroment locally for development. Production is on EngineYard / GitHub. All now working ok, except DB isn't importing.

I have a .sql file that i've taken from my prod EY site. Now i need to import it to my MySQL locally. I'm using Workbench (as i'm new to this), but getting error below.

Please help?

08:07:43 Restoring /home/james/Downloads/Futology.sql Running: mysql --defaults-extra-file="/tmp/tmpAVeE58/extraparams.cnf" --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments < "/home/james/Downloads/Futology.sql" ERROR 1046 (3D000) at line 22: No database selected

Operation failed with exitcode 1 08:07:43 Import of /home/james/Downloads/Futology.sql has finished with 1 errors

6

There are 6 answers

2
charliequinn On BEST ANSWER

Not used Workbench too much however it's easy enough to do from command line have a look at this (below phpMyAdmin instructions)

The command you're after is: mysql -u #username# -p #database# < #dump_file#

0
brynn On

Here's another option that worked for me. I'm using MySQL 5.5 on a VM I set up for importing a large MySQL .sql dump that contained: 1). a create table statement 2). insert statements for inserting a large amount of data into the table. at the MySQL command line client prompt type:

use yourdatabasename
source d:\yourpath\yourfilename.sql

for more info on the 'source' and other commands, enter ? at the prompt.

1
Kirk Woll On

Similar to brynn's answer, simply modify your SQL file and insert the following line at the very top:

use yourdatabasename

Replacing yourdatabasename with the database into which you are trying to import. Also, this database should already be created (albeit empty) before you import into it.

0
steve On

The above command line is correct. I found I have to do this when importing .sql files from older versions of MySQL. I also found I had to edit the .sql file (top of the file) and set the db name to be the same as the blank db you create before doing the import.

0
Chuqi Cha On

Simply by choosing your target schema

Simply by choosing your target schema

As I circled in above image

0
Brad Hunter On

Workbench doesn't know the database (schema) you want to use.

In workbench, when using Data Import/Restore, just below where you choose the file to import, it asks "Default Schema to be Imported To"

Just choose the database (schema) you want it to use from the dropdown titled Default Target Schema. If you don't have a database (schema) already, you can create it with the "New" button.

This is confusing because MySQL generally seems to use the term database but Workbench uses schema. They mean the same thing for most purposes. MySQL 'create schema' and 'create database' - Is there any difference