This Problem with WordPress on the Localhost Usually come from a Not Proper Setting for the Host Parmeter…
To Solve Try to Set you Host to:
127.0.0.1
-
Open for Editing the wp-config.php
-
Set the host to -> “127.0.0.1”
To Get some Extra-Insight Look this other Guide:
WordPress Connect to Remote MySQL Database