Skip to content

importer.import crashing because of server variables in dump file #67

@johndanek

Description

@johndanek

Describe the bug
I am attempting to feed the output of the npm library mysqldump into mysql-import in an AWS SAM function. The error I receive is:

2023-03-06T17:34:03.171Z	2e91bc57-df7f-410c-9452-76acd78a52ae	INFO	 - Import 0% Completed
2023-03-06T17:34:03.175Z	2e91bc57-df7f-410c-9452-76acd78a52ae	ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"Encoding not recognized: 'undefined' (searched as: 'undefined')","stack":[
  "Error: Encoding not recognized: 'undefined' (searched as: 'undefined')","
    at Object.getCodec (/var/task/node_modules/iconv-lite/lib/index.js:104:23)","
    at Object.getEncoder (/var/task/node_modules/iconv-lite/lib/index.js:115:23)","
    at exports.encode (/var/task/node_modules/mysql-import/node_modules/mysql2/lib/parsers/string.js:23:25)","
    at Query.toPacket (/var/task/node_modules/mysql-import/node_modules/mysql2/lib/packets/query.js:16:30)","
    at Query.start (/var/task/node_modules/mysql-import/node_modules/mysql2/lib/commands/query.js:60:38)","
    at Query.execute (/var/task/node_modules/mysql-import/node_modules/mysql2/lib/commands/command.js:45:22)","
    at Connection.handlePacket (/var/task/node_modules/mysql-import/node_modules/mysql2/lib/connection.js:456:32)","
    at Connection.addCommand (/var/task/node_modules/mysql-import/node_modules/mysql2/lib/connection.js:478:12)","
    at Connection.query (/var/task/node_modules/mysql-import/node_modules/mysql2/lib/connection.js:546:17)","
    at /var/task/node_modules/mysql-import/mysql-import.js:466:23"
]}

I have a hunch that the issue is due to the dump file beginning with the following lines:

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */
/*!40101 SET NAMES utf8 */
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */

If I manually delete these lines from the file, it seems to work. But the error is definitely a little confusing. Is this expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions