我正在教自己如何通过在Lynda观看Kevin Skoglund电影来编码。我在本系列的其中一章中遇到了麻烦 - 创建一个数据库。我正在尝试登录MySQL,但显示如下 -
Rosss-MacBook-Air:~ rossnyland$ mysql -user -p
Enter password:
ERROR 1045 (28000): Access denied for user 'ser'@'localhost' (using password: YES)
Rosss-MacBook-Air:~ rossnyland$
密码是正确的,因为当我输入错误的密码时,它会说(使用密码:否)
我做错了什么? MySQL server is running
,我正在使用5.7.20 version
,使用MAC OS x
,并尝试登录mysqlworkbench,但会弹出消息说
Your connection attempt failed for user 'root' from your host to server at localhost:3306:
Access denied for user 'root'@'localhost' (using password: YES)
Please:
1 Check that mysql is running on server localhost
2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the root has rights to connect to localhost from your address (mysql rights define what clients can connect to the server and from which machines)
4 Make sure you are both providing a password if needed and using the correct password for localhost connecting from the host address you're connecting from
即使我试图删除它但没有成功!请告诉我我做错了什么或如何重新开始...
答案 0 :(得分:2)
密码可能是正确的,但我怀疑您的用户是ser
。
当您使用命令行选项-u
时,您放在其后面的任何文本都是用户名。
因此,如果您的mysql用户名为mysql_user
,则需要:
$ mysql -umysql_user -p
或:
$ mysql -u mysql_user -p
或:
$ mysql --user=mysql_user --password
答案 1 :(得分:0)
对于命令行工具错误,您可能提供了错误的命令。它应该是:
$ mysql -u username -p
对于MySQL Workbench错误,有两种可能:
localhost
界面上收听。换句话说,检查bind_ip
配置文件中my.cnf
的值。在这种情况下,您应该通过--host
选项提供实际的IP地址。您还可以查看我之前发布的this answer,它会向您显示解决此类问题的完整步骤。