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
Step 2
Connect to the server using the MySQL user and hostname specified during the installation process. Use the command below
\connect root@localhost
root
represent the user, whilelocalhost
represents the hostname
See the screenshot below
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;
Summary
In this article, we learned how to fix the Unexpected Identifier
error when using MySQL shell
.