简体   繁体   English

如何通过 mysql workbench 将数据导入 mysql 数据库?

[英]How can I import data into mysql database via mysql workbench?

I created a database in mysql.我在mysql中创建了一个数据库。 I have a .sql file.我有一个 .sql 文件。 how can i import it into my database via mysql workbench ?如何通过 mysql workbench 将其导入我的数据库?

  • Under Server Administration on the Home window select the server instance you want to restore database to (Create New Server Instance if doing it first time).在主页窗口的服务器管理下,选择要将数据库还原到的服务器实例(如果是第一次执行,则创建新的服务器实例)。
  • Click on Manage Import/Export单击管理导入/导出
  • Click on Data Import/Restore on the left side of the screen.单击屏幕左侧的数据导入/恢复
  • Select Import from Self-Contained File radio button (right side of screen)选择从自包含文件导入单选按钮(屏幕右侧)
  • Select the path of .sql选择.sql的路径
  • Click Start Import button at the right bottom corner of window.单击窗口右下角的开始导入按钮。

Hope it helps.希望能帮助到你。

---Edited answer--- ---编辑答案---

Regarding selection of the schema.关于模式的选择。 MySQL Workbench (5.2.47 CE Rev1039) does not yet support exporting to the user defined schema. MySQL Workbench (5.2.47 CE Rev1039) 尚不支持导出到用户定义的模式。 It will create only the schema for which you exported the .sql... In 5.2.47 we see "New" target schema.它将只创建您导出 .sql 的架构...在 5.2.47 中,我们看到“新”目标架构。 But it does not work.但它不起作用。 I use MySQL Administrator (the old pre-Oracle MySQL Admin beauty) for my work for backup/restore.我使用 MySQL Administrator(旧的 pre-Oracle MySQL Admin 美容)进行备份/恢复工作。 You can still download it from Googled trustable sources (search MySQL Administrator 1.2.17).您仍然可以从谷歌搜索的可信来源下载它(搜索 MySQL Administrator 1.2.17)。

For MySQL Workbench 6.1: in the home window click on the server instance(connection)/ or create a new one.对于 MySQL Workbench 6.1:在主窗口中单击服务器实例(连接)/ 或创建一个新实例。 In the thus opened 'connection' tab click on 'server' -> 'data import'.在如此打开的“连接”选项卡中,单击“服务器”->“数据导入”。 The rest of the steps remain as in Vishy's answer.其余步骤与 Vishy 的回答相同。

  1. Open Connetion开放连接
  2. Select "Administration" tab选择“管理”选项卡
  3. Click on Data import点击数据导入

Upload sql file上传sql文件

在此处输入图片说明

Make sure to select your database in this award winning GUI:确保在这个屡获殊荣的 GUI 中选择您的数据库:

在此处输入图片说明

For MySQL Workbench 8.0 navigate to:对于MySQL Workbench 8.0,导航到:

Server > Data Import

A new tab called Administration - Data Import/Restore appears.出现一个名为Administration - Data Import/Restore 的新选项卡。 There you can choose to import a Dump Project Folder or use a specific SQL file according to your needs.在那里您可以根据需要选择导入转储项目文件夹或使用特定的 SQL 文件。 Then you must select a schema where the data will be imported to, or you have to click the New... button to type a name for the new schema.然后,您必须选择将数据导入到的模式,或者您必须单击新建...按钮为新模式键入名称。

Then you can select the database objects to be imported or just click the Start Import button in the lower right part of the tab area.然后您可以选择要导入的数据库对象或直接单击选项卡区域右下方的开始导入按钮。

Having done that and if the import was successful, you'll need to update the Schema Navigator by clicking the arrow circle icon.完成后,如果导入成功,您将需要通过单击箭头圆圈图标来更新Schema Navigator

That's it!就是这样!

For more detailed info, check the MySQL Workbench Manual: 6.5.2 SQL Data Export and Import Wizard有关更多详细信息,请查看MySQL Workbench 手册:6.5.2 SQL 数据导出和导入向导

It ok, if I import nearly 8GB of SQL file, Is this the correct way.没关系,如果我导入将近 8GB 的​​ SQL 文件,这是正确的方法吗? If yes means how should i speed up the importing process.如果是意味着我应该如何加快导入过程。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM