error message from a particular request in WP site : Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] connexion refused
error message from PhpMyAdmin when trying to connect to Local DB : mysqli::real_connect(): (HY000/2002): Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée
Troubleshooting Questions
Does this happen for all sites in Local, or just one in particular?
just for PDO requests. Other DB access ok.
same trubble trying to connect with PhpMyAdmin
Are you able to create a new, plain WordPress site in Local and access it in a Browser?
Yes
Replication
basic sample WP site + “independent Analytics” plugin. ‘geo’ tab in plugin admin page.
This seems like a plug-in-specific issue since the error is originating from Independent Analytics itself.
One of our Local Devs checked the Query.php file, downloaded from the free plugin version, and it looks like the plugin tries to connect to the wp db directly via PHP’s PDO library using some custom connection logic. If it connected using WPDB calls instead that would allow it to work with more varied environments, including Local.
Similarly, with PhpMyAdmin - it’s as if the database isn’t being referred/pointed to correctly.
Are you able to use Adminer? Local handles the pointing in that instance so that may be telling if it works for you or not.
PhpMyAdmin : just can’t use adminer having PhpMyAdmin.
Problem solved as mentioned in your given link, and the same way to solve PDO connexion problem with Local (see below).
PDO connexion with Local : don’t think realy a plugin specific issue, since perfectly work in production (6000+ active installs, see map widget at : [https://observatoiredelajustice.org]).