Common SQL Errors

MySQL Error 1342: ER_FPARSER_EOF_IN_COMMENT - Fix Unexpected EOF in Comment

Galaxy Team
August 6, 2025

MySQL raises error 1342 when the parser reaches the end of a script while still inside an unclosed SQL comment.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1342 (ER_FPARSER_EOF_IN_COMMENT)?

MySQL Error 1342: ER_FPARSER_EOF_IN_COMMENT means the parser hit the end of your SQL file while still inside a comment block. Close the /* ... */ or -- comment, verify statement delimiters, and rerun the script to resolve the problem.

Error Highlights

Typical Error Message

Unexpected end of file while parsing comment '%s'

Error Type

Syntax Error

Language

MySQL

Symbol

ER_FPARSER_EOF_IN_COMMENT

Error Code

1342

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 1342 (ER_FPARSER_EOF_IN_COMMENT)?

Error 1342 appears with message "Unexpected end of file while parsing comment '%s'" when MySQL's parser finishes reading a script but never finds the closing delimiter for an opened comment.

The failure halts execution because MySQL cannot decide where the current statement or comment ends, making the entire batch syntactically invalid.

What Causes This Error?

An unterminated C-style comment that starts with /* and never receives a matching */ is the most common trigger.

Missing newlines after a double-dash -- comment can also fool the parser into thinking the rest of the file is still part of the same comment.

How to Fix MySQL Error 1342: ER_FPARSER_EOF_IN_COMMENT

Locate the last opened comment in the failing script and add the correct closing delimiter before the file ends.

If using -- comments, ensure a space or line break follows the dashes so MySQL recognizes the end of the comment line.

Common Scenarios and Solutions

Long migration scripts often use DELIMITER ;; blocks. Forgetting to reset the delimiter can prevent comment termination; add DELIMITER ; after the procedure or function.

Copy-pasting code from other editors can drop trailing */ characters. Run a text-search for /* without a matching */ to spot the problem fast.

Best Practices to Avoid This Error

Adopt syntax-aware editors like Galaxy that highlight matching comment delimiters in real time, reducing the chance of leaving a block open.

Commit SQL scripts to version control and run them through CI linters that flag unterminated comments before they reach production.

Related Errors and Solutions

Error 1064 (syntax error) often surfaces when an unterminated comment is present but the file does not end; closing the comment resolves both errors.

Error 1267 (illegal mix of collations) can sometimes mask as a parsing failure; confirming comment closure helps narrow down the real root cause.

Common Causes

Unclosed /* ... */ Block

A developer opens a C-style comment and forgets the */ token before file end.

Missing Newline after -- Comment

Using -- without a following space or line break causes MySQL to treat the remainder of the script as part of the comment.

Delimiter Changes in Procedures

Changing DELIMITER to ;; within stored procedure definitions and not switching back can confuse the parser when comments follow.

Copy-Paste Errors

Moving code between editors may strip closing comment symbols, leaving blocks open.

Related Errors

Error 1064: You have an error in your SQL syntax

Broad syntax error that may appear when a comment is left open but the file continues.

Error 1235: This version of MySQL doesn't yet support '...'

Sometimes happens when comment blocks wrap unsupported statements; closing the comment reveals the true issue.

Error 1267: Illegal mix of collations

Displayed when MySQL misinterprets the rest of the file as one long string due to an unclosed comment.

FAQs

Does this error only affect /* ... */ comments?

No. An inline -- comment without a trailing space or newline can also trigger error 1342 if it reaches the end of file.

Can I disable comment parsing to avoid the issue?

No. Comment parsing is integral to MySQL's syntax engine. Instead, ensure all comments are properly closed.

Why does my IDE not flag the error but MySQL does?

Some editors use generic SQL grammars. Tools like Galaxy use version-specific parsers that detect MySQL-specific comment rules.

Will the entire transaction roll back when this error occurs?

If the script runs in autocommit=0 and a START TRANSACTION block precedes the error, MySQL rolls back the partial work automatically.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo