php 用户@'localhost' 对数据库 '' 的访问被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8621649/
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
access denied for user @ 'localhost' to database ''
提问by expiredninja
I'm seeing a lot of of similar questions to this. but can't find one exactly like mine yet. Not sure where to change these settings or anything, any help appreciated.
我看到很多与此类似的问题。但还没有找到和我一模一样的。不知道在哪里更改这些设置或任何东西,任何帮助表示赞赏。
access denied Access denied for user ''@'localhost' to database ''
This is the beginning of my page.
这是我页面的开头。
$dbhost = 'localhost'; //unlikely to require changing.
$dbname ='publication'; //modify these
$dbuser = 'username'; //variables
$dbpass = ''; //// to your installation
$appname = 'application name'; // and preference
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
采纳答案by gama_jr
Try this: Adding users to MySQL
试试这个:将用户添加到 MySQL
You need grant privileges to the user if you want external acess to database(ie. web pages).
如果您想从外部访问数据库(即网页),则需要向用户授予权限。
回答by Clay Freeman
You are most likely not using the correct credentials for the MySQL server. You also need to ensure the user you are connecting as has the correct privileges to view databases/tables, and that you can connect from your current location in network topographic terms (localhost).
您很可能没有为 MySQL 服务器使用正确的凭据。您还需要确保您所连接的用户具有查看数据库/表的正确权限,并且您可以从网络拓扑术语 (localhost) 的当前位置进行连接。