简体   繁体   English

MySQL Workbench 6.1 - 导入记录集时出错

[英]MySQL Workbench 6.1 - Error importing recordset

I'm going to be getting a new computer soon and I don't want to lose all of the data I have entered in my tables, so I decided to test out the feature that allows you to export and import CSV files. 我很快就会得到一台新电脑而且我不想丢失我在表格中输入的所有数据,因此我决定测试允许您导出和导入CSV文件的功能。 I exported a table successfully (data was transferred to Microsoft Excel in CSV file), but when I opened the file in Microsoft Excel and added a few rows and tried to import it back in to MySQL Workbench, I got the following error: 我成功导出了一个表(数据已经转移到CSV文件中的Microsoft Excel),但是当我在Microsoft Excel中打开文件并添加了几行并尝试将其重新导入MySQL Workbench时,我收到以下错误:

"Error importing recordset

error calling Python module function
SQLIDEUtils.importRecordsetDataFromFile"

I've searched all over for info on this, but can't find any solutions. 我已经搜索了所有关于此的信息,但找不到任何解决方案。 Does anyone know what I'm doing wrong? 有谁知道我做错了什么?

In Workbench, open a MySQL connection and then navigate to [Server] --> [ Data Export ]. 在Workbench中,打开MySQL连接,然后导航到[Server] - > [ Data Export ]。 There are several backup options here, including saving the data as an individual file or folder. 这里有几个备份选项,包括将数据保存为单个文件或文件夹。 Choose the databases you want to export, and then click [Start Export]. 选择要导出的数据库,然后单击[开始导出]。

If you ever prefer using Excel for editing and such, then use the MySQL for Excel plugin to access MySQL databases from within Excel. 如果您更喜欢使用Excel进行编辑等,请使用MySQL for Excel插件从Excel中访问MySQL数据库。 However, I don't think you need it here. 但是,我认为你不需要它。

To export your mySQL data, use mysqldump , which will create all the schema for you. 要导出mySQL数据,请使用mysqldump ,它将为您创建所有架构。

Excel probably added some stuff to your file and now mySQL can't understand it. Excel可能在你的文件中添加了一些东西,现在mySQL无法理解它。 The best way to find out is by comparing the files before and after the change. 找出答案的最佳方法是比较更改前后的文件。

That error indicates a format problem. 该错误表示格式问题。 If the file is small enough, try opening it in wordpad (or the mac equivalent) and see if there's any difference in the formatting? 如果文件足够小,尝试在wordpad(或等效的mac)中打开它,看看格式是否有任何差异? Could be that the delimiting got a little messed up (this can happen especially with end of row markers in MySQL, I've noticed, it can also happen in mac to pc handoffs). 可能是划分有点混乱(这可能发生在MySQL的行标记结束时,我注意到,它也可能发生在mac到pc切换)。 If all else fails you could try exporting using a different format and see if that makes a difference (maybe tsv) when you add new rows. 如果所有其他方法都失败了,您可以尝试使用其他格式导出,并在添加新行时查看是否会产生差异(可能是tsv)。

Another reason can be the line endings used. 另一个原因可能是使用的行结尾。 Depending on the system and editor used to work with the cvs file it the line endings might get changed. 根据用于处理cvs文件的系统和编辑器,行结尾可能会更改。 For me mysql supported UNIX line endings. 对我来说mysql支持UNIX行结尾。 And in the editor the line ending had been set to MAC OS 9 since I was using a MAC. 在编辑器中,由于我使用MAC,因此行结束已设置为MAC OS 9。 Changing it to UNIX line ending worked. 将其更改为UNIX行结束工作。

I found that it might be due to a wrong encoding of the input file. 我发现它可能是由于输入文件的编码错误造成的。 Using Notepad++ for example (or another similar editor) you need to change file encoding to UTF-8. 例如,使用Notepad ++(或其他类似的编辑器),您需要将文件编码更改为UTF-8。

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

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