无法连接到数据库:拒绝访问用户“@ @ localhost”到数据库'socialdb' [英] Unable to connect to database: Access denied for user ''@'localhost' to database 'socialdb'
本文介绍了无法连接到数据库:拒绝访问用户“@ @ localhost”到数据库'socialdb'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到这样的错误,但我没有找到答案。
I've seen a few errors like this, but I found no answer.
Unable to connect to database: Access denied for user ''@'localhost' to database 'socialdb'
socialdb是我的数据库。 无法连接到数据库:部分位于此处。
socialdb is my database. The "Unable to connect to database:" part is located here.
$db = mysql_select_db("socialdb",$con);
if(!$db) {
die ('Unable to connect to database: ' . mysql_error());
}
我不知道是什么原因造成的。这是我的mysql_connect详情
I don't know what's causing this. Here are my mysql_connect details
<?php
$con = mysql_connect("localhost");
if(!$con) {
die ('Error: ' . mysql_error());
}
我需要找到根。非常感谢。
I need to find the root. Thanks.
我没有MySQL用户名或密码
I DON'T HAVE A USERNAME OR PASSWORD FOR MySQL
p>
Should it be this?
mysql_connect("localhost","","");
推荐答案
错误是不言自明的,不允许连接而不指定一些凭据。
The error is pretty self-explanatory, you're not allowed to connect without specifying some credentials.
将您的通话更改为 mysql_connect()
如下:
Change your call to mysql_connect()
to something like this:
mysql_connect("localhost", "user", "password");
这篇关于无法连接到数据库:拒绝访问用户“@ @ localhost”到数据库'socialdb'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文