如何从Windows命令提示符连接到mysql命令行 [英] How to connect from windows command prompt to mysql command line
问题描述
我正在尝试从Windows提示符下连接到mysql服务器命令行
I'm trying to connect to mysql server command line from my windows prompt
我在cmd中写下一行,但是出现错误.
I write the next line in cmd but i get an error.
cd C:\MYSQL\bin\
然后我执行
mysql.exe -u=root -p=admin
但我收到此错误
ERROR 1045: <28000>: Access denied for user 'root'@'localhost' <using password:YES>
谢谢
推荐答案
问题中的cd
无效(在这里引用它是因为您已将其删除一次,并且在发布此答案时就已在其中):
The cd
in your question is invalid (quoting it here because you've removed it once, and it was there when this answer was posted):
cd CD:\MYSQL\bin\
您不能cd
到CD:\
任何东西,因为CD:\
在Windows中不是有效目录. CD:
表示驱动器,但驱动器仅限于A
和Z
之间的单个字母.
You can't cd
to CD:\
anything, because CD:\
isn't a valid directory in Windows. CD:
would indicate a drive, except that drives are restricted to a single letter between A
and Z
.
如果\MYSQL\BIN
在驱动器C:
上,则您的命令必须为:
If your \MYSQL\BIN
is on drive C:
, then your commands need to be:
C:\>cd \MYSQL\Bin
C:\MYSQL\Bin>mysql -u root -p admin
如果尚未使用C:
(通过查看cmd窗口中的提示即可知道),或者您的MySQL文件夹位于另一个驱动器上(例如,D:
),请更改为也开车:
If you're not already on C:
(which you'll know by looking at the prompt in the cmd window), or your MySQL folder is on another drive (for instance, D:
), change to that drive too:
C:\> cd /d D:\MYSQL\Bin
D:\MYSQL\Bin>mysql -u root -p admin
mysql
之后的.exe
是可选的,因为.exe
是Windows上的可执行扩展.如果键入mysql
,Windows将自动查找具有该名称的可执行文件,并在找到该文件后运行它.
The .exe
after mysql
is optional, since .exe
is an executable extension on Windows. If you type mysql
, Windows will automatically look for an executable file with that name and run it if it finds it.
请注意,在我的两个运行mysql
的示例中,都没有=
符号.您应该只使用-p
而不输入密码,然后等待提示它.
Note that in both my examples of running mysql
, there are no =
signs. You should just use -p
with no password, and wait to be prompted for it instead.
这篇关于如何从Windows命令提示符连接到mysql命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!