MySQL: SyntaxError: Unexpected identifier

MysqlSql

Mysql Problem Overview


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?

Mysql Solutions


Solution 1 - Mysql

By looking at this thread here, it looks like you might be using the shell in js mode, you might be able to toggle it off by using the switch

\sql 

https://forums.mysql.com/read.php?10,661192,661203#msg-661203

Solution 2 - Mysql

You can type:

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

and provide your password.

Solution 3 - Mysql

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 4 - Mysql

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

Solution 5 - Mysql

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)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSlaknationView Question on Stackoverflow
Solution 1 - MysqlMax CarrollView Answer on Stackoverflow
Solution 2 - MysqlRahul PrasadView Answer on Stackoverflow
Solution 3 - MysqlMelanie ShebelView Answer on Stackoverflow
Solution 4 - MysqlHari RaviView Answer on Stackoverflow
Solution 5 - MysqlAryan SrivastavaView Answer on Stackoverflow