mysql shell 无法连接到 mysql 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44481917/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql shell is not able to connect to mysql server
提问by M thaker
I am using windows machine. Everything is successfully installed. When I try to write mysql-js> mysql -u root -p
in my MySql shell , it is showing unexpected identifier
error. What should I write to connect to the mysql server?
我正在使用 Windows 机器。一切都安装成功。当我尝试mysql-js> mysql -u root -p
在 MySql shell 中写入时,它显示unexpected identifier
错误。我应该写什么来连接到mysql服务器?
回答by naruto_1906
Just check you are in which mode. To go in sql mode
只需检查您处于哪种模式即可。进入 sql 模式
mysql-js> \sql
To connect:
连接:
mysql-js> \connect root@localhost
and enter password
并输入密码
回答by Bill Karwin
It looks like you are trying to run the mysql
program from within the mysql client shell. This is wrong. You can run mysql
only at a command.exeprompt.
看起来您正在尝试mysql
从 mysql 客户端 shell 中运行该程序。这是错误的。您mysql
只能在command.exe提示符下运行。
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>
At this point, you're in the mysql shell, which has been run from the Windows command shell. You can't run programs within the mysql shell, but you don't have to.
此时,您处于 mysql shell 中,该 shell 已从 Windows 命令 shell 运行。您不能在 mysql shell 中运行程序,但您不必这样做。
This is documented here: https://dev.mysql.com/doc/refman/5.7/en/mysql.html
这在此处记录:https: //dev.mysql.com/doc/refman/5.7/en/mysql.html
Once you are in the mysql shell, you can connect to a new server with the connect
command. But this is uncommon to do this. It's sufficient to connect when you invoke the mysql shell.
进入 mysql shell 后,您可以使用该connect
命令连接到新服务器。但这样做并不常见。调用mysql shell 时连接就足够了。
mysql> connect mydatabase 127.0.0.1
The user & password used for this connection are the ones you specified when you first invoked the mysql shell.
用于此连接的用户和密码是您第一次调用 mysql shell 时指定的用户和密码。
This is documented here: https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html
这在此处记录:https: //dev.mysql.com/doc/refman/5.7/en/mysql-commands.html
回答by Hein
You may want/need to switch to SQL more using \sql - see \help for help
您可能想要/需要更多地使用 \sql 切换到 SQL - 请参阅 \help 以获取帮助
回答by shruthi_kr
try this
尝试这个
\connect root@localhost
later id it is in JS mode switch to sql
后来id是在JS模式切换到sql
\sql
check out this blog Starting off with MySQL shell 8.0 on Windows