Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 933
RedCuber Avatar asked Apr 26 '11 07:04

RedCuber


People also ask

How do I fix error code 1046 in MySQL?

Now, we can choose any database. Suppose I am using the database 'business', therefore we can choose with the help of 'use' command. After using database 'business', we can create the above table and we will not get any error.

How do I fix no database selected in MySQL workbench?

If the error arises due to not selecting a database, you can easily overcome it by replacing [database_name] with the correct database name in your server. When creating a table statement from the MySQL workbench, you need to select the database to run before executing the statement.

Why it is showing no database selected error in MySQL?

The error no database selected frequently occurs in MySQL when you perform a statement without selecting a database first. You need to replace [database_name] with the name of a database that exists in your MySQL server.


2 Answers

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

like image 70
Brad Hunter Avatar answered Oct 14 '22 01:10

Brad Hunter


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#

like image 21
charliequinn Avatar answered Oct 14 '22 02:10

charliequinn