'MySQL: SyntaxError: Unexpected identifier

I just installed MySQL on my computer and when I try to create a database from the MySQL shell, I get this error:

MySQL  JS > CREATE DATABASE databasename;
SyntaxError: Unexpected identifier

Does anyone know why this is happening? Is there a problem with the installation of MySQL?



Solution 1:[1]

You can type:

Mysql JS>  \sql
Mysql SQL>  \connect root@localhost

and provide your password.

Solution 2:[2]

Logging in as follows did work as shown by Rahul in another answer:

Mysql JS>  \sql
Mysql SQL>  \connect root@localhost

However, I was able to get Mysql> instead of Mysql JS> or Mysql SQL> by opening the Windows command prompt and entering the following:

mysql -u root -p

Solution 3:[3]

try using connect root@localhost and then try \sql to switch to sql mode if the default mode is JS.

Solution 4:[4]

After using \connect root@localhost code, I am still getting the following error, even after putting in my password: MySQL Error 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (10061)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brian Tompsett - 汤莱恩
Solution 2
Solution 3 Hari Ravi
Solution 4 Aryan Srivastava