简体   繁体   English

使用MySQL WorkBench导入...错误ERROR 1046(3D000)

[英]Importing using MySQL WorkBench… error ERROR 1046 (3D000)

Scenario: building a RoR enviroment locally for development. 场景:在本地构建RoR环境以进行开发。 Production is on EngineYard / GitHub. 生产在EngineYard / GitHub上。 All now working ok, except DB isn't importing. 现在一切正常,但DB没有导入。

I have a .sql file that i've taken from my prod EY site. 我有一个.sql文件,我从我的prod EY网站上获取。 Now i need to import it to my MySQL locally. 现在我需要在本地将它导入我的MySQL。 I'm using Workbench (as i'm new to this), but getting error below. 我正在使用Workbench(因为我是新手),但在下面得到错误。

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 08:07:43恢复/home/james/Downloads/Futology.sql运行:mysql --defaults-extra-file =“/ tmp / tmpAVeE58 / extraparams.cnf”--host = localhost --user = root --port = 3306 --default-character-set = utf8 --comments <“/ home / james / Download /Futology.sql”ERROR 1046(3D000)第22行:未选择数据库

Operation failed with exitcode 1 08:07:43 Import of /home/james/Downloads/Futology.sql has finished with 1 errors 操作失败,使用exitcode 1 08:07:43导入/home/james/Downloads/Futology.sql已完成1个错误

Workbench doesn't know the database (schema) you want to use. Workbench不知道您要使用的数据库(模式)。

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. 只需从标题为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. 这很令人困惑,因为MySQL通常似乎使用术语数据库,但Workbench使用模式。 They mean the same thing for most purposes. 对于大多数目的,它们意味着同样的事情 MySQL 'create schema' and 'create database' - Is there any difference MySQL'创建模式'​​和'创建数据库' - 有什么区别

Not used Workbench too much however it's easy enough to do from command line have a look at this (below phpMyAdmin instructions) 没有使用Workbench太多但是从命令行做起来很容易看看这个 (在phpMyAdmin说明下面)

The command you're after is: mysql -u #username# -p #database# < #dump_file# 你所追求的命令是: mysql -u #username# -p #database# < #dump_file#

Simply by choosing your target schema 只需选择目标模式即可

只需选择目标模式即可

As I circled in above image 当我在上面的图像中盘旋

Similar to brynn's answer, simply modify your SQL file and insert the following line at the very top: 与brynn的答案类似,只需修改您的SQL文件并在最顶部插入以下行:

use yourdatabasename

Replacing yourdatabasename with the database into which you are trying to import. 更换yourdatabasename与到您正在尝试导入数据库。 Also, this database should already be created (albeit empty) before you import into it. 此外,在导入数据库之前,应该已经创建了该数据库(尽管是空的)。

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). 我在我设置的VM上使用MySQL 5.5,用于导入包含以下内容的大型MySQL .sql转储:1)。 a create table statement 2). 一个create table语句2)。 insert statements for inserting a large amount of data into the table. 插入用于将大量数据插入表中的语句。 at the MySQL command line client prompt type: 在MySQL命令行客户端提示符下键入:

use yourdatabasename
source d:\yourpath\yourfilename.sql

for more info on the 'source' and other commands, enter ? 有关'source'和其他命令的更多信息,请输入? at the prompt. 在提示。

The above command line is correct. 上面的命令行是正确的。 I found I have to do this when importing .sql files from older versions of MySQL. 我发现从旧版本的MySQL导入.sql文件时我必须这样做。 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. 我还发现我必须编辑.sql文件(文件顶部)并将db名称设置为与导入之前创建的空白数据库相同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MySQL“ERROR 1046(3D000):未选择数据库”更新查询 - MySQL “ERROR 1046 (3D000): No database selected” on update query 第1行的错误1046(3D000):未选择数据库 - ERROR 1046 (3D000) at line 1: No database selected ERROR 1046 (3D000) at line 22: No database selected, when restore database using deitch/mysql-backup - ERROR 1046 (3D000) at line 22: No database selected, when restoring database using deitch/mysql-backup 创建过程错误1046(3D000):未选择数据库 - Create procedure ERROR 1046 (3D000): No database selected 错误1046(3D000):创建用户时未选择数据库 - ERROR 1046 (3D000): No database selected while creating user codeigniter 3.1 PDO mysql错误号:3D000 / 1046未选择数据库 - codeigniter 3.1 PDO mysql Error Number: 3D000/1046 No database selected 致命错误:未捕获的 PDOException:SQLSTATE [3D000]:无效的目录名称:1046 未选择数据库 - Fatal error: Uncaught PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected 错误显示为“ SQLSTATE [3D000]:无效的目录名称:1046未选择数据库” - Getting error as “ SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected ” laravel 看不到我的本地主机数据库错误:SQLSTATE [3D000]:目录名称无效:1046 未选择数据库 - laravel not seeing my localhost database error : SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected SQLSTATE [3D000]:无效的目录名称:1046未选择数据库 - SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM