21

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());
expiredninja
  • 1,397
  • 4
  • 25
  • 45

2 Answers2

20

Try this: Adding users to MySQL

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

Marc.2377
  • 7,807
  • 7
  • 51
  • 95
gama_jr
  • 216
  • 1
  • 3
4

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

Clay Freeman
  • 533
  • 5
  • 17
  • how do i change these things? – expiredninja Dec 23 '11 at 23:55
  • 1
    You have to use the credentials that you used when setting up MySQL for one, for the other things, Google is your best friend.. :) I recommend using the user 'root' if possible. It has all the rights necessary to do anything. That would narrow down your inquiry to just being able to connect, and using the right credentials. – Clay Freeman Dec 23 '11 at 23:58