title: ACCESS DENIED to mysql DB with PHP but can login with phpmyadmin and on the command line
body: <p><strong>Blew away that server, restarting fresh. WAY too much time wasted on this!</strong></p>
  
  <p>Let me know if I left any details out please. Have spent about a week researching this and trying things to no avail.</p>
  
  <p>Creating a website (first time) for my upcoming wedding and I would like my guests to be able to post comments to the site. I am a professional software engineer but not a web dev so this was my attempt at teaching myself more about php and perl and learning to work with Linux.</p>
  
  <p>Setup LAMP on Ubuntu 12.0.4 hosted on Amazon. Followed standard setup tutorial online. Apache2 with PHP5.</p>
  
  <p>Created new MYSQL users (names changed for obvious reasons) user@localhost and user@% with passwords. All privileges granted to both (even on the specific DB), then flushed. Firewall port 3306 opened. bind-address in the mysql config file set to 0.0.0.0 or commented out (have tried both). Made sure not to start it with --skip-networking.</p>
  
  <p>I can connect with user@localhost just fine when I run mysql -u user -hlocalhost -p as well as with phpmyadmin on the web. Correct privileges (including GRANT) are shown when I query that and I have granted each user full access to the DB I created for the site.</p>
  
  <p>Now my issue is when using php or perl I cannot connect to the DB from the webpage or from running the scripts on the command line (such as sudo php script.php).</p>
  
  <p>Here is the line of my php script that fails, I can post the perl if anyone would like:</p>
  
  <pre><code>mysql_connect("localhost", "user", "password")or die( mysql_error());
  </code></pre>
  
  <p>No matter what I do I get this error when running the script:</p>
  
  <p>Access denied for user 'user'@'localhost' (using password: YES)</p>
  
  <p>Same error, every dang time.</p>
  
  <p>Now because I can log in with those same credentials through the command line and phpmyadmin I have to assume it is a setting I have messed somewhere on the server. I don't know what else to check aside from what I already have and what feels like hundreds of answers I have read on the subject haven't helped. If anyone could offer some advice that would be great, I am at wits end and about to trash the entire server and start fresh.</p>
  
  <p>Or if no one has an answer for this, any other way I can achieve my end goal of having users be able to post comments to the site?</p>