简体   繁体   English

无法通过命令行连接到本地主机MySQL数据库?

[英]Can't connect to localhost MySQL database through command line?

Weird issue. 奇怪的问题。 Can't connect to localhost MySQL database from command line, but I can through MySQL program, Sequel Pro. 无法从命令行连接到本地主机MySQL数据库,但我可以通过MySQL程序Sequel Pro。 Any ideas why? 有什么想法吗? I entered the same user/password, but I'm getting a access denied error for root@localhost 我输入了相同的用户名/密码,但是我收到了root @ localhost的拒绝访问错误

Extra question: can you run MySQL commands within Sequel Pro? 额外的问题:您可以在Sequel Pro中运行MySQL命令吗? I'm pretty new to MySQL, but I'm just trying to change a simple column definition. 我对MySQL很陌生,但是我只是想更改一个简单的列定义。

EDIT: reset password from within Sequel Pro query for root, and was able to get it working. 编辑:从Sequel Pro查询中重设root密码,并能够使其正常工作。

MySQL has different accesses. MySQL具有不同的访问权限。 You can allow a MySQL database to only serve requests from a specific machine, or only from the local machine. 您可以允许MySQL数据库仅处理来自特定计算机或仅来自本地计算机的请求。

However, note that MySQL differentiates login from "localhost" and from "127.0.0.1". 但是,请注意,MySQL将登录名与“ localhost”和“ 127.0.0.1”区分开。

Try allowing both localhost, 127.0.0.1 and "%" to the account. 尝试同时允许localhost,127.0.0.1和“%”访问该帐户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM