Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
拒绝用户访问';用户'@';本地主机';关于MySQL_Mysql_Database_Mysql Error 1045 - Fatal编程技术网

拒绝用户访问';用户'@';本地主机';关于MySQL

拒绝用户访问';用户'@';本地主机';关于MySQL,mysql,database,mysql-error-1045,Mysql,Database,Mysql Error 1045,我正在尝试将我连接到数据库MySQL服务器,但控制台显示错误1045(28000):用户“root”@“localhost”的访问被拒绝(使用密码:是)我不知道为什么。请帮帮我。在我的文件my.cnf中,我有这样的东西 [mysqld] datadir=/var/lib/mysql socket=/tmp/mysql.sock user=mysql # Default to using old password format for compatibility with mysql 3.x #

我正在尝试将我连接到数据库MySQL服务器,但控制台显示错误1045(28000):用户“root”@“localhost”的访问被拒绝(使用密码:是)我不知道为什么。请帮帮我。在我的文件
my.cnf
中,我有这样的东西

[mysqld]
datadir=/var/lib/mysql
socket=/tmp/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# To allow mysqld to connect to a MySQL Cluster management daemon, uncomment
# these lines and adjust the connectstring as needed.
#ndbcluster
#ndb-connectstring="nodeid=4;host=localhost:3306"

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[ndbd]
# If you are running a MySQL Cluster storage daemon (ndbd) on this machine,
# adjust its connection to the management daemon here.
# Note: ndbd init script requires this to include nodeid!
connect-string="nodeid=2;host=localhost:3306"

[ndb_mgm]
# connection string for MySQL Cluster management tool
connect-string="host=localhost:3306"

[client]
socket=/tmp/mysql.sock


谢谢。

-p
标志表示需要密码。输入请求密码的内容后,应该会出现第二个提示。例如:

$ mysql -u root -p
$ Enter password: 

然后键入密码。

如果你真的不记得通行证了,你可以在
my.cnf
[mysqld]
部分添加
跳过授权表,重新启动服务器,它将允许你无需密码进入,然后,您可以通过更新
mysql.user
table来更改密码,并重新启动mysql,删除
skip\u grant\u tables
选项。

您可以演示如何通过控制台进行连接吗?(如果命令行提供密码,请输入密码)当然可以,
Hectors MacBook Pro:~hlozano$mysql-uroot-p
您在安装过程中设置了密码吗?:)只需在密码提示下点击
Enter
,没有帮助吗?你确定你输入的密码正确吗?(很抱歉有明显的问题,我只是想确定一下):)哦,当然,我重新安装了MySQL服务器,因为它没有启动数据库。当我重新启动我的MAC时,我没有进入数据库。如果你真的不记得密码了,你可以在my.cnf的
[mysqld]
部分添加
skip_grant_tables
,重新启动服务器,它会让你在没有密码的情况下进入,然后,您可以通过更新
mysql.user
表来更改密码,并重新启动mysql,删除
skip\u grant\u tables
选项。