首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mysql shell无法连接到mysql服务器

mysql shell无法连接到mysql服务器
EN

Stack Overflow用户
提问于 2017-06-11 16:41:02
回答 5查看 34.4K关注 0票数 14

我用的是windows机器。一切都已成功安装。当我试图在我的MySql外壳中编写mysql-js> mysql -u root -p时,它显示了unexpected identifier错误。要连接到mysql服务器,我应该写什么?

EN

回答 5

Stack Overflow用户

发布于 2018-02-14 19:41:45

只需检查您处于哪种模式。进入sql模式

代码语言:javascript
复制
mysql-js> \sql

要连接:

代码语言:javascript
复制
mysql-js> \connect root@localhost

并输入密码

票数 39
EN

Stack Overflow用户

发布于 2019-03-12 18:19:09

尝尝这个

代码语言:javascript
复制
\connect root@localhost

稍后的id是JS模式,切换到sql

代码语言:javascript
复制
\sql

请查看此博客Starting off with MySQL shell 8.0 on Windows

票数 5
EN

Stack Overflow用户

发布于 2017-07-11 14:27:29

看起来您正在尝试从mysql客户端外壳中运行mysql程序。这是错误的。您只能在command.exe提示符下运行mysql

代码语言:javascript
复制
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 shell中,该shell是从Windows命令shell运行的。您不能在mysql shell中运行程序,但您不必这样做。

这里记录了这一点:https://dev.mysql.com/doc/refman/5.7/en/mysql.html

一旦进入mysql shell,就可以使用connect命令连接到新服务器。但这样做并不常见。当您调用mysql shell时,连接就足够了。

代码语言:javascript
复制
mysql> connect mydatabase 127.0.0.1

用于此连接的用户名和密码是您在第一次调用mysql shell时指定的用户名和密码。

这里记录了这一点:https://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44481917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档