Bitnami WAMP - phpmyAdmin - Access denied for user 'root'@'localhost' (using password: YES)

I am using the Bitnami WAMP and have tested the connection to a db with a small program.  It worked fine.  I load up a more complex program and I get the

mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)

I have a screenshot showing that the privileges for all users is yes. The only difference between the two is that I am using this for the connection

DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', '#######');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'ecommerce');

// Make the connection:
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

// Set the character set:
mysqli_set_charset($dbc, 'utf8');
error
JohnMac328Asked:
Who is Participating?
 
Dave BaldwinFixer of ProblemsCommented:
Do you have both IIS and WAMP on the same machine?  But only one install of MySQL (the one in WAMP)?  IIS normally takes over / hogs 'localhost' so there may be a conflict there.  On my machine with WAMP, I do not have IIS.

Can you create another MySQL user with '%' anyhost access and use the machine IP to connect instead of 'localhost'?

PS: I just had to open up port 3306 on my WAMP machine so I could access MySQL remotely instead of using 'localhost'.  You might need to do the same thing to use an IP address instead of 'localhost'.
0
 
Dave BaldwinFixer of ProblemsCommented:
Assuming you are running that on the same machine that the WAMP is on, the only reason that would fail is if you typed the password wrong.
0
 
JohnMac328Author Commented:
Same one as the test db that connects with no problem.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Dave BaldwinFixer of ProblemsCommented:
Sorry, that doesn't make any sense.  If the two scripts act different it is because there is a difference.
0
 
JohnMac328Author Commented:
Here is the first
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="######"; // Mysql password
$db_name="ecommerce"; // Database name


Here is the second
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', '######');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'ecommerce');

// Make the connection:
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

The only difference is the connection mysqli_connect  as opposed to
mysql_connect("$host", "$username", "$password")or die("cannot connect");

I know it does not make sense - that's why I came here :)
0
 
Dave BaldwinFixer of ProblemsCommented:
Here's the page http://php.net/manual/en/mysqli.construct.php for 'mysqli_connect '.  Try doing it inline like in the procedural example instead of using DEFINE.  Here's the page for DEFINE: http://php.net/manual/en/function.define.php
0
 
JohnMac328Author Commented:
Shows a syntax error with this line

$dbc = mysqli_connect ([ string $host = ini_get("localhost") [, string $username = ini_get("root") [, string $passwd = ini_get("######") [, string $dbname = "ecommerce" [, int $port = ini_get("mysqli.default_port") [, string $socket = ini_get("mysqli.default_socket") ]]]]]] )
0
 
Dave BaldwinFixer of ProblemsCommented:
Yes, it would.  There are a lot of extra '[]' characters in that line that are supposed to tell you that some of the parameters are optional.

I tried your original code above with the DEFINE statements using my own info in my WAMP installation and, after I cleaned up my errors, it worked fine.
0
 
JohnMac328Author Commented:
Ok then the only other thing that is different is that the code is in a file that is outside of the root - here is how it connects

define ('BASE_URI', '../../ecommerce2securefiles/');
define ('BASE_URL', 'http://localhost:8080/ecommerce/');
define ('MYSQL', BASE_URI . 'mysql.inc.php');
0
 
Dave BaldwinFixer of ProblemsCommented:
I suggest you do a simple test file inside the root that includes all the needed info and does not depend on any of those 'defines'.  You can always erase it when you are done.  But that will tell you if the 'defines' are part of the problem.
0
 
JohnMac328Author Commented:
Seems like it - I just did this and it connects

$Connection = mysql_connect("localhost", "root", "######") or die("Could not connect");
   $dbc = mysql_select_db("ecommerce", $Connection) or die("Could not select database");

But it bombs in some code in the header that once again has a problem with mysqli

mysqli_query() expects parameter 1 to be mysqli, boolean given

Here is the code part - it bombs on the $r line
$q = 'SELECT * FROM categories ORDER BY category';
$r = mysqli_query($dbc, $q);
0
 
Dave BaldwinFixer of ProblemsCommented:
On any given connection, you have use either 'mysql' or 'mysqli'.  You can not use both together.  They are completely different drivers and methods and they do Not work together.
0
 
JohnMac328Author Commented:
I am testing with my small program.  I changed what I can see from mysql to mysql.  It is connecting but not displaying the records.  Can you see where I have not correctly changed from mysql to mysqli?  I am new to php

Thanks

//$host="localhost"; // Host name 
//$username="root"; // Mysql username 
//$password="######"; // Mysql password 
//$db_name="maxibillions"; // Database name 
//$tbl_name="employee_data"; // Table name 

// Connect to server and select databse.
//mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
//mysql_select_db("$db_name")or die("cannot select DB");

DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', '######');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'maxibillions');

// Make the connection:
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);



//$q = 'SELECT * FROM categories ORDER BY category';
//$r = mysqli_query($dbc, $q);

$sql="SELECT * FROM employee_data WHERE active_account = '1'";
$result=mysqli_query($dbc, $sql);

//$count=mysql_num_rows($result);
 $rowcount=mysqli_num_rows($result);
?>
<html>
<body>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td colspan="4" bgcolor="#FFFFFF"><center>
<strong>Delete multiple Records in MySQL</strong> </center></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td>
</tr>
<?php
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>"></td>
<td bgcolor="#FFFFFF"><?php echo $row['id']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $row['first_name']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $row['last_name']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $row['email_name']; ?></td>
</tr>
<?php
}
?>

<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF">
<input name="delete" type="submit" id="delete" value="Delete">
<input name="delete" type="submit" id="delete" value="Refresh" onClick="<meta http-equiv=\"refresh\" content=\"0;URL=del.php\">
</td>
</tr>

</table>
</form>
</td>
</tr>
</table>
</body>
</html>
<?php

// Check if delete button active, start this  

// if(isset($_POST['delete'])){ 

// for($i=0;$i<count($_POST['checkbox']);$i++){ 

// $del_id = $_POST['checkbox'][$i]; 

// $sql = "UPDATE $tbl_name
//SET active_account= '0'
//WHERE id='$del_id'"; 

//$result = mysql_query($sql); 

//} 

// if successful redirect to delete_multiple.php 
//if($result){
//echo "<br>";
//echo "<h3> Record is successfully deleted. </h3>";
//echo "<br><br>";
// echo "<meta http-equiv=\"refresh\" content=\"0;URL=del.php\">";
//}
//}
// mysql_close();
?>

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
I copied your code, put in my own database info, and it works fine.  What errors are you getting?
0
 
JohnMac328Author Commented:
No error - just no records displaying
0
 
JohnMac328Author Commented:
Dang - I threw in error handling and got this - the WAMP I am running has a problem with mysqli - same problem as the first program

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\Bitnami\wampstack-5.4.39-0\apps\DCheckBox\htdocs\index.php on line 22
0
 
Dave BaldwinFixer of ProblemsCommented:
That warning comes from MySQL thru the PHP 'mysqli' driver and it is telling you that there is something wrong with your login.  It is not because of your version of WAMP.  I've been running the tests for your code on another machine where I have WAMP installed so I could use 'localhost' and I am not seeing that problem using my own login info.  I also have a copy on this machine that I can use to connect remotely to several other MySQL servers I have running here.
0
 
JohnMac328Author Commented:
This info connects

//$host="localhost"; // Host name
//$username="root"; // Mysql username
//$password="######"; // Mysql password
//$db_name="maxibillions"; // Database name
//$tbl_name="employee_data"; // Table name

 I am using the same info when I use this and it does not connect
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', '######');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'maxibillions');

// Make the connection:
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

The only difference is mysqli as opposed to mysql - two different programs - both can connect with mysql and both cannot with mysqli using WAMP.

Both programs connect with IIS using
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', '######');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'maxibillions');

// Make the connection:
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

So it is not a wrong PW etc
0
 
JohnMac328Author Commented:
I changed the port setting in php.ini under the WAMP install since the default was 3306

Here is more detailed info

http://blog.ulf-wendel.de/2011/using-mysql-with-php-mysqli-connections-options-pooling/

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.