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

Melanie Shebel's user avatar

asked Jun 1, 2018 at 14:14

Slaknation's user avatar

2

You can type:

Mysql JS>  sql
Mysql SQL>  connect root@localhost

and provide your password.

Brian Tompsett - 汤莱恩's user avatar

answered Aug 18, 2019 at 8:02

Rahul Prasad's user avatar

4

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

answered Feb 6, 2021 at 14:04

Melanie Shebel's user avatar

Melanie ShebelMelanie Shebel

2,6246 gold badges31 silver badges49 bronze badges

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

answered Dec 21, 2021 at 3:49

Hari Ravi's user avatar

2

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)

answered Feb 7, 2022 at 18:18

Aryan Srivastava's user avatar

1

Cover image for 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.

In this article, we will see the solution for below error

SyntaxError: Unexpected identifier

MySQL SyntaxError Unexpected identifier


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

This error is observed in latest MySQL Shell. We can’t directly run the queries after opening MySQL shell. First, we have to switch to sql mode and connect with the user.

1. Switch to sql

sql

2. Now, connect to MySQL user and hostname.

connect root@localhost

If we want to connect using different user other than root user, run the following command.

connect david@localhost

So in this article, we have seen solution for MySQL Syntax error i.e. Unexpected identifier.

I’m trying to follow this guide: https://dev.mysql.com/doc/world-setup/en/world-setup-installation.html

  1. Connect to the MySQL server using the mysql command-line client with the following command:

    shell> mysql -u root -p

I typed this exact command into the MySQL shell, and it does not work, it gives the error «SyntaxError: Unexpected Identifier»:

MySQL Shell SyntaxError: Unexpected Identifier

I also tried just typing mysql and it prints out <mysql>, not very helpful.

I also tried skipping the first step and typing SOURCE C:/temp/world.sql; (including by replacing that path with the actual path to my world.sql) and it says «SyntaxError: Unexpected Identifier».

I also tried typing SOURCE by itself and it says «ReferenceError: SOURCE is not defined».

I’m quite confused, I have no idea what I’m missing, I think I’m following the guide correctly. I’m using MySQL 8.0.21.

asked Sep 12, 2020 at 1:07

Aaron Franke's user avatar

Aaron FrankeAaron Franke

1,1536 gold badges23 silver badges36 bronze badges

1

I believe I had the same problem with the normal mysql client several years ago.

The solution then was to use -uroot (note the missing space character between the option and the user name). You could also try --user=root.

Please don’t flame me if this does lead nowhere. With my current installation, I can’t reproduce the problem; plus, I don’t use MySQL shell. However, I believe chances are good that it works with one of the above solutions.

answered Sep 12, 2020 at 8:48

Binarus's user avatar

On this specific shell u have to enter the command: connect roo@localhost:3306 if u want to connect as the admin
and to use SQL command, u have to proceed like this for example sql use mysql to selct mysql database. So every SQL commands has to begin by sql

mysql guide: https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-commands.html

answered Jul 15, 2021 at 23:43

Xtine's user avatar

Перейти к контенту

Cover image for 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.

In this article, we will see the solution for below error

SyntaxError: Unexpected identifier

MySQL SyntaxError Unexpected identifier


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

This error is observed in latest MySQL Shell. We can’t directly run the queries after opening MySQL shell. First, we have to switch to sql mode and connect with the user.

1. Switch to sql

sql

2. Now, connect to MySQL user and hostname.

connect root@localhost

If we want to connect using different user other than root user, run the following command.

connect david@localhost

So in this article, we have seen solution for MySQL Syntax error i.e. Unexpected identifier.

Я только что установил MySQL на свой компьютер, и когда я пытаюсь создать базу данных из оболочки MySQL, я получаю эту ошибку:

MySQL  JS > CREATE DATABASE databasename;
SyntaxError: Unexpected identifier

Кто-нибудь знает, почему это происходит? Может проблема с установкой MySQL?


57

Slaknation

1 Июн 2018 в 17:14

Глядя на эту тему здесь, похоже, что вы используете оболочку в режиме js, вы можете отключить ее с помощью переключателя

sql 

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


59

Max Carroll
1 Июн 2018 в 14:18

Issue

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

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

Answered By – Max Carroll

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Похоже, вы пытаетесь запустить программу mysql из оболочки клиента mysql. Это не верно. Вы можете запустить mysql только в командной строке.

C:> mysql -u root -p
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 72
Server version: 8.0.1-dmr MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>

На данный момент вы находитесь в оболочке mysql, которая была запущена из командной оболочки Windows. Вы не можете запускать программы в оболочке mysql, но вам этого не нужно.

Это описано здесь: https://dev.mysql.com/doc/refman/5.7/en/mysql.html

Когда вы находитесь в оболочке mysql, вы можете подключиться к новому серверу с помощью команды connect. Но это редкость. Это достаточно для соединения при вызове оболочки mysql.

mysql> connect mydatabase 127.0.0.1

Пользователь и пароль, используемые для этого соединения, — это те, которые вы указали при первом вызове оболочки mysql.

Это описано здесь: https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html

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?

Answer

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

Attribution
Source : Link , Question Author : Slaknation , Answer Author : Max Carroll

Ezoic

Понравилась статья? Поделить с друзьями:
  • Mysql no packages found ошибка
  • Mysql no compatible servers were found ошибка
  • Name httpresponse is not defined django ошибка
  • Nalog ru ошибка генерации сертификата попробовать еще раз
  • Nabco автоматические двери ошибки