Database Connection Issues
Posted by: Patabugen (---.range86-171.btcentralplus.com)
Date: October 13, 2016 05:48PM

Recently (I think since Wamp 3.0) my PHP is having trouble connecting to the database about 20% of the time.

It seems to be a resource limit problem - e.g. if I open 10 tabs then all of them will fail to connect, but if I only open one and refresh it a few times it'll usually work then occasionally not work.

I have 10 WordPress sites installed locally and it seems to happen equally with all of them.

MySQL: 5.7.14 (I tried another version before reinstalling but I'm not sure which one)
PHP: 5.6.25 and 7.0.10
Apache: 2.4.23
Wamp: 3.0.6 64bit

I just tried reinstalling from scratch and get the same problems - all files and configs are stock except changing the location of my vhosts file.

There's nothing in any error logs that I can find (Windows Event Viewer or ones linked via WampManager), I've tried increasing MySQL's connection_limit to 500 (from 150) and checked whether Windows has any TCP connection limits (it doesn't appear to).

I'm at a loss for what else to check or try. The same code works perfectly in production (all be it on slightly different versions).

Options: ReplyQuote
Re: Database Connection Issues
Posted by: Patabugen (---.range86-171.btcentralplus.com)
Date: October 13, 2016 06:21PM

I just tried installing MySQL 5.7.15 which is giving me the same problems.
MySQL 5.7.16 isn't working at all - I cannot modify users because it says a password field is missing.

Options: ReplyQuote
Re: Database Connection Issues
Posted by: RiggsFolly (Moderator)
Date: October 13, 2016 09:19PM

I cannot modify users because it says a password field is missing.

Sorry, but that description of your problem is really not any use to us at all

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Database Connection Issues
Posted by: Patabugen (---.range86-171.btcentralplus.com)
Date: October 14, 2016 04:50PM

RiggsFolly Wrote:
-------------------------------------------------------
> I cannot modify users because it says a
> password field is missing.

>
> Sorry, but that description of your problem is
> really not any use to us at all

It was a basic explanation of why I've not tried solving my actual problem by updating to the latest version - I have no desire to fix it and that's not what I'm asking for help with.

If you think the core issue sounds like a bug in both previous versions of MySQL I'll put more effort into making 5.7.16 work, however!

Options: ReplyQuote
Re: Database Connection Issues
Posted by: Patabugen (---.range86-171.btcentralplus.com)
Date: October 17, 2016 01:18PM

I've fixed this issue.

PHP in WampServer (or perhaps PHP in all WAMP setups) appear to share variables set via `putenv` between processes - causing a library I was using for setting environment variables to freak out.

More details if anyone is interested:
[github.com]

Options: ReplyQuote
Re: Database Connection Issues
Posted by: Otomatic (Moderator)
Date: October 17, 2016 03:13PM

Hi,

Quote
Patabugen
The actual issue which caused me to look into this is my WAMP stack which appears to be sharing get/putenv variables between simultaneous processes. So if I load my page 10 times the first would work, but all the other requests would fail because $_ENV['DB_HOST'] is not set because phpdotenv saw it in getenv and then did not set the $_ENV (which I use).

Entirely normal operation.
It is the opposite that would be a huge security hole.
If it worked as you would like, it would mean that a user who logs on a web page could have access to all data of other users connected to the same page.
Fortunately, it does not work like that.

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



Edited 1 time(s). Last edit at 10/17/2016 03:19PM by Otomatic.

Options: ReplyQuote


Sorry, only registered users may post in this forum.