MySQL 命令行打不开?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4508420/
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 command line won't open?
提问by Gaurav
I just installed the latest version of MySQL. Until Now I had it on Windows XP but I wanted to install this on another computer with Windows 7.
我刚刚安装了最新版本的 MySQL。到目前为止,我在 Windows XP 上安装了它,但我想在另一台装有 Windows 7 的计算机上安装它。
Even after configuring everything correctly, the MySQL client won't show up in the Start Folder. So I went to the bin folder of MySQL and tried opening mysql.exe but it would immediately close down.
即使正确配置了所有内容,MySQL 客户端也不会显示在启动文件夹中。所以我去了MySQL的bin文件夹并尝试打开mysql.exe,但它会立即关闭。
I then tried opening mysql.exe in cmd & this is what I get
然后我尝试在 cmd 中打开 mysql.exe & 这就是我得到的
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N
O)
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: N
O)
Any Ideas how I can get this to work?
我有什么想法可以让它发挥作用吗?
采纳答案by Mchl
Provide username (root)
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -uroot
提供用户名(root)
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -uroot
Default passsword is blank, but if you set it, you will need to provde password as well
默认密码为空,但如果您设置它,您还需要提供密码
回答by Herschel
I don't recall where I first read it, but when facing this problem before, I found that I had to manually turn on a service:
我不记得我第一次读到哪里了,但是之前遇到这个问题时,我发现我不得不手动开启一个服务:
- Windows key+R and type Run and hit "enter"
- Type "services.msc", hit "OK"
- Find "MySQL56", right-click and choose "Start"
- You should now be able to log in with no trouble
- Windows 键 + R 并键入运行并按“输入”
- 输入“services.msc”,点击“确定”
- 找到“MySQL56”,右击选择“开始”
- 您现在应该可以毫无问题地登录了
That's the solution that worked for me; hopefully it helps others out there.
这就是对我有用的解决方案;希望它可以帮助其他人。
回答by Crouch
What @Herschel said is right if you follow his steps 1-4 then try to log in with your password in command line you'll have no trouble.
@Herschel 说的是对的,如果您按照他的步骤 1-4 操作,然后尝试在命令行中使用您的密码登录,您就不会遇到任何问题。
You can also make this run automatically as a service, something which you need when running it on a server.
您还可以将其作为服务自动运行,这是在服务器上运行时需要的。
- Open Run
- Type "services.msc" click ok
- Find the MySQL service
- Right-click properties then go down to startup type:
- Change it to automatic
- 打开运行
- 输入“services.msc”点击确定
- 查找 MySQL 服务
- 右键单击属性,然后转到启动类型:
- 改成自动
回答by SunilA
I followed these steps and it worked for me:
我按照以下步骤操作,它对我有用:
1. Open Command prompt in admin and go to the location of Mysql bin folder and type -
C:\ProgramFile\mysql\bin>mysql -u root -p <password>
2. Then the prompt asks for the password. This is the password or the root user which
you had set during installation of mysql.
3. Type the password and you will login in to mysql.
4. Also make sure your mysql service is running in the backend by going to the
windows service panel and check whether the mysql service is running.