Warning: mysqli::__construct(): (HY000/1045)
Posted by: Alamoosook (---.44.241.133.res-cmts.segc.ptd.net)
Date: January 20, 2020 04:46PM

I have (had) a working program. The configuration was Windows Server 2008 and WAMP Server 2.2. The server was upgraded to Windows Server 2016. I removed the old WAMP Server completely, including deleting the c:\wamp directory (well I renamed it). I loaded new version (3.2) of 64-bit WAMP Server. I created my databse and then loaded it from exported previously db.sql file. I changed the RootDirectory to c:\www and loaded my application to c:\www\app_name\. I set up a root password from phpMyAdmin. The phpMyAdmin has no problems. I tested the password by connecting using the root credentials from command line, it worked. But an attempt to connect in PHP code gives me an error.
The offfending line is:
$mysqli = new mysqli($GLOBALS['mysql_host_name'], $GLOBALS['mysql_user_id'], $GLOBALS['mysql_user_password'], $GLOBALS['mysql_db_name']);
I verified the contents of the $GLOBAL variables and I also tried plugging in the actual values directly.
The error is:
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)
Any ideas?
Richard

Options: ReplyQuote
Re: Warning: mysqli::__construct(): (HY000/1045)
Posted by: Otomatic (Moderator)
Date: January 20, 2020 05:51PM

Hi,

There is a php script for trying to connect to a database.

wamp64/www/testmysql.php

Edit this file to put the right values ($password and $database) then launch it from the Wampserver homepage ('http://localhost/') by 'http://localhost/testmysql.php'.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Warning: mysqli::__construct(): (HY000/1045)
Posted by: Alamoosook (---.44.241.133.res-cmts.segc.ptd.net)
Date: January 20, 2020 11:28PM

Otomatic, thanks for your reply. Unfortunately the link does not seem to work...
Regards,
Richard

Options: ReplyQuote
Re: Warning: mysqli::__construct(): (HY000/1045)
Posted by: Otomatic (Moderator)
Date: January 21, 2020 09:33AM

Hi,

> Unfortunately the link does not seem to work...
What link are you talking about? I mentioned a file, not a link!

The file wamp64/www/testmysql.php

Which you have to edit to put the right values for $password and $database.

Then launch the Wampserver homepage 'http://localhost/'.

And in the address bar of the browser type: 'http://localhost/testmysql.php'.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Warning: mysqli::__construct(): (HY000/1045)
Posted by: Alamoosook (---.44.241.133.res-cmts.segc.ptd.net)
Date: January 22, 2020 04:23PM

Sorry, at first I thought the file was supposed to be available on the wamp site. Yes, I located it on the machine with the wamp server installation. I have solved the problem by then but it would have helped me to resolve it faster. It was a port mismatch. For some reason MariaDB installed as default and MySQL was not using the default port. Once you know it the whole thing becomes trivial. Once again, thanks for responding.

Options: ReplyQuote
Re: Warning: mysqli::__construct(): (HY000/1045)
Posted by: Otomatic (Moderator)
Date: January 22, 2020 06:32PM

Hi,

> It was a port mismatch.

With Wampserver 3.2.0 MariaDB is the default database manager, MySQL is only installed on option.
At the end of the installation, a message warns :

For some explanations on how Wampserver works, see the file:
wamp(64)\instructions_for_use.rtf or wamp(64)\instructions_for_use.pdf

In this file, there is :
--- Support of MariaDB
Read the file "mariadb_mysql.txt" into the wamp install directory

And there is :
Right-Click -> Help -> MariaDB - MySQL

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.