access denied for user @ 'localhost' to database '' [closed]

社会主义新天地 提交于 2019-11-26 12:19:17

问题


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());

回答1:


Try this: Adding users to MySQL

You need grant privileges to the user if you want external acess to database(ie. web pages).




回答2:


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).



来源:https://stackoverflow.com/questions/8621649/access-denied-for-user-localhost-to-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!