DEV Community

Cover image for How to fix MySQL Syntax Error: Unexpected Identifier
Emmanuel Fordjour  Kumah
Emmanuel Fordjour Kumah

Posted on

24

How to fix MySQL Syntax Error: Unexpected Identifier

MySQL is one of the most recommended tools for managing and organizing data in a database. In this article, I outline steps to help fix the error Syntax Error: Unexpected Identifier when connecting to the MySQL shell server

Why the error?

This error mostly occurs when using the MySQL shell in JS mode, preventing users from directly running queries after launching the MySQL shell.

Fixing the Syntax Error

To fix the error, you have to switch the shell to SQL mode and connect to the server.

Step 1:

Switch the MySQL shell from JS to SQL mode using the command below;



\sql


Enter fullscreen mode Exit fullscreen mode

sql

Step 2

Connect to the server using the MySQL user and hostname specified during the installation process. Use the command below



\connect root@localhost


Enter fullscreen mode Exit fullscreen mode
  • root represent the user, while localhost represents the hostname

See the screenshot below

sql

Congrats, you have resolved the error and can proceed to create a database.

Lastly, if you want to create a database, the command to use is as below



create database databaseName;

Enter fullscreen mode Exit fullscreen mode




Summary

In this article, we learned how to fix the Unexpected Identifier error when using MySQL shell.

API Trace View

Struggling with slow API calls? đź‘€

Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (2)

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
efkumah profile image
Emmanuel Fordjour Kumah •

Glab to be of help

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay