Jump to content


Photo

WAMP -> acces denied for user...


  • Please log in to reply
2 replies to this topic

#1 MichelDS

MichelDS

    Member

  • Members
  • PipPip
  • 29 posts
  • LocationBelgium - Vlaams-brabant

Posted 29 April 2012 - 12:17 PM

I had IIS on my laptop -> desinstalled and cleaned the register with Ccleaner, also did it by hand whats left of it, also deleted every trace left on disk C.
I had skype on my laptop -> desinstalled and cleaned the register with Ccleaner, also did it by hand whats left of it, also deleted every trace left on disk C.
I restarted my laptop.

I installed WAMP, the latest version available today.

The wamp icon stayed orange when I activated the wampserver and went never into green.
In httpd.confIg I changed the port  into  Listen 8081, I restarted WAMPserver and the icon went finally green. 
ONLY then I could open phpMyAdmin en was able to open localhost:8081.

Now I wanted to test the connection :
<?php
$db_host = "localhost";
$db_user= "root@localhost";
$db_pass = '';
$db_name = "projecteasywebsite";
    

//connect to mysql database server
mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error());
echo "Successfully connected to MySQL Database!<br><br>";
 
//Select Database
mysql_select_db($db_naam) or die (mysql_error());
echo '<h2>Successfully selected ' . $db_name . ' database!</h2>';
?>
It gave as a result :
Successfully connected to MySQL Database!

Access denied for user ''@'localhost' to database 'projecteasywebsite'


I've been searchin for houres now on the net and tried different things, I also created a new user in PHPMYADMIN and got the same results back -> Access denied for ...

I even changed the hostname -> $db_host = "localhost:8081";  and  the page kept buzzy searching for a connection or... So no result was brought from localhost:8081

So why did'n the icon turned into green the first time ?
Why did I had to change the port to 8081  for having acces to PHPMYADMIN and localhost:8081 ?

The problem is in my opinion related to this. But I have no clue whatsoever ! And I searched for houres but all solutions I found didn't helped.

Are there hard core people here who can help me please ?


#2 gizmola

gizmola

    Advanced Member

  • Administrators
  • 4,102 posts
  • LocationLos Angeles, CA USA

Posted 29 April 2012 - 02:31 PM

In this type of setup all you need to do to connect to mysql is provide the host of 'localhost'.  This worked, as shown in your script.

MySQL does listen on a well known port, but that is nothing you need to be concerned about.  Don't confuse the php script connecting to the mysql database with a web application like phpmyadmin.  Web apps listen on port 80 by default, but in setups like this, they use a different port for administration web applications, just to keep things simple for people.  Phpmyadmin is nothing other than a php script that connects to mysql in the same way your php script connects to it. 

Now let's focus on what your mistake was....


//connect to mysql database server
mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error());
echo "Successfully connected to MySQL Database!<br><br>";
 
//Select Database
mysql_select_db($db_naam) or die (mysql_error());

Notice that your code told you it connected fine.  It was on the mysql_select_db call that you got an error.

Hmm, let's look at your variables: 

$db_name = "projecteasywebsite";

And you tried to select the database with this:

mysql_select_db($db_naam) or die (mysql_error());

See the problem with the database name variable?



#3 MichelDS

MichelDS

    Member

  • Members
  • PipPip
  • 29 posts
  • LocationBelgium - Vlaams-brabant

Posted 29 April 2012 - 05:20 PM

Yes indeed, that was the error at the end. i have been staring too long at those codes I guess. But in the beginning there was really something strange going on with the wamp setup. But now it works and that's the point. So thank you for that.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com