By brajendrashukla on
when starting an existing project on another computer. As the repository wasn't online already, I had to copy the whole D7 folder from PC1 to PC2, and import the database in phpMyAdmin. I've got this error as result when accessing my (localhost) homepage.
PDOException: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'localhost' (10061) in lock_may_be_available()
plz help me
Comments
When I get this error, it's
When I get this error, it's always something wrong in settings.php. Take another look at what you've got in there for your db settings -- it sounds like the db info is different from PC1 to PC2.
Quickest Fix For Me
Got similar error after site was disabled, put offline during a backup.
When site came online this error showed for the Drupal MySQL DB.
If moving to new hardware or network, etc. The contents of the 'settings.php' will have to be updated.
1. Locate the 'settings.php' file (should be in [drupal home dir]/sites/default/settings.php)
a. Find the "$databases = array ( 'default' => ..........." entry
b. The above should have the name of your database and user account information.
Make sure the appropriate database name, user name, etc. are specified in this file.
NOTE: the settings.php file has permissions set to read-only. You will have to temporarily change this to Read-Write to modify it - then change it back when done.
same problem...
I checked my settings and its correct but it's strange how I still get that error. I am on Amazon web services and I have my RDS database instance connected to my EC2.
I can connect through the shell but on the browser it gives me that exception.
Really strange. Any suggestions ppl?
In sites - default
Sorry if this is obvious to others, but I wanted to make a note for myself that this is in /sites/default/settings.php.
I moved to a new server and had to update my database username, password, and host.
Thanks for explaining this error message!
same
I had the same problem, but I have a doubt. I want to know how I configure my database("settings.php") to be accessible from any PC that I can use to manage my site.
SELinux
I had this problem when installing a site on a CentOS server, connecting to a database on another server. It turned out the connection to the database was being prevented by SELinux. Issuing the following command (as root) told SELinux to allow the connection:
setsebool httpd_can_network_connect_db=1Thank you for posting this.
@alxbridge, Thank you for posting this.
That was it for me. Thx!
That was it for me. Thx!
PDOException: SQLSTATE[HY000] [2003] Can't connect error
Best way to handle this error is when you switch your drupal website from one host to another that delete your settings.php file
and switch to host where you place your drupal website .then it ask to install drupal and their are two option first add new site and second use previous site if we select second option then your drupal site will appear their and new settings.php created automatically with require configuration...I solved problem this way
previous site
So do you have a fresh install of Drupal 7 or your previous site installed on the web server?
Let me know. Thanks.
best recommendation on the web
This so worked for me in terms of permissions problems and database.
https://www.howtoforge.com/centos-7-drupal-installation
For AWS support on drupal on EC2 and RDS, this youtube vid was great and on the money.
https://www.youtube.com/watch?v=6eawpxMHoJU
If you host with godaddy
If you host with godaddy please visit this link https://www.godaddy.com/help/viewing-your-database-details-with-shared-h...
thanks
Thats a perfect solution
SELinux resolved it
We had the same problme on one of our Drupal Systems. The problem happened after restarting the webServer. The Error message was
We did not have any problem conencting to Mysql from command line on the same server but the Drupal PHP Code had the above issue. SELinux was enabled after the server was restarted. Permanently disabling SELinux resolved the issue. Update the file /etc/selinux/config and add/update this line