MySQL Forums
Forum List  »  Install & Repo

Re: Error Connecting to DataBase!: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
Posted by: Amanda J
Date: October 07, 2017 03:25PM

Unfortunately I do not know what the "web browser navigator control" is?

So I did the following:

From a Chrome browser I typed "localhost" into the address bar.

This opens the WAMP home page (where I am trying to access website from).
I can also get to this page through the WAMP GUI.

"localhost/index.php" gets me to the same place

testmysql.php

<?php
$mysqli = new mysqli('127.0.0.1', 'root', '', '');

if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}
echo '<p>Connection OK '. $mysqli->host_info.'</p>';
echo '<p>Server '.$mysqli->server_info.'</p>';
$mysqli->close();
?>

Returns:
Connection OK 127.0.0.1 via TCP/IP
Server 5.7.19

test_sockets.php

<?php
if (extension_loaded('sockets')) {
	//Create socket IPv4
	$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) ;
	if($socket === false) {
		$errorcode = socket_last_error() ;
		$errormsg = socket_strerror($errorcode);
		echo "<p>Error socket IPv4: ".$errormsg."</p>\n" ;
	}
	else {
		echo "<p>Socket IPv4 supported</p>\n" ;
		socket_close($socket);
	}

	//Create socket IPv6
	$socket = socket_create(AF_INET6, SOCK_STREAM, SOL_TCP) ;
	if($socket === false) {
		$errorcode = socket_last_error() ;
		$errormsg = socket_strerror($errorcode);
		echo "<p>Error socket IPv6: ".$errormsg."</p>\n" ;
	}
	else {
		echo "<p>Socket IPv6 supported</p>\n" ;
		socket_close($socket);
	}
}
else echo "<p>Extension PHP sockets not loaded</p>\n" ;
?>
Returns:
Socket IPv4 supported
Socket IPv6 supported

From the WAMP GUI I can open the mysql console (c:\wamp64\bin\mysql\mysql5.7.19\bin\mysql.exe)

mysql>show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| possbil            |
| sys                |
+--------------------+

If I select the db, run simple queries, I get a result returned
    mysql>use possbil;
    mysql>SHOW TABLES;
    mysql>SELECT * FROM table_a;

mysql> create user 'test'@'localhost' identified by 'test123';
Query OK, 0 rows affected (0.00 sec)

mysql> grant select on test.* to 'test'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> select user from mysql.user;
+---------------+
| user          |
+---------------+
| mysql.session |
| mysql.sys     |
| root          |
| test          |
+---------------+

test.php file (localhost/test.php)

<?php 
$conn = mysqli_connect("localhost", "test", "test123", "possbil" ) or exit( mysqli_connect_error() ); 
echo "Connected"; 
?>

Returns

( ! ) Warning: mysqli_connect(): (HY000/1044): Access denied for user 'test'@'localhost' to database 'possbil' in C:\wamp64\www\test.php on line 2
Call Stack
#	Time	Memory	Function	Location
1	0.0005	235360	{main}( )	...\test.php:0
2	0.0005	235728	mysqli_connect ( )	...\test.php:2
Access denied for user 'test'@'localhost' to database 'possbil'

A quick check of the user table in phpmyadmin shows the new "test" user to be there, but with no privileges?

On the DNS I ran:
C:\Users\AmandaJ>ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
But selecting the possbil directory from the WAMP home page still show same error (I may need to re-boot?)

Options: ReplyQuote


Subject
Written By
Posted
Re: Error Connecting to DataBase!: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
October 07, 2017 03:25PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.