Drupal 7 PDOException Unknown MySQL server host
I just ran into a situation of getting a Drupal 7 "PDOException Unknown MySQL server host" error message while running Drupal 7 on a GoDaddy server. The full Drupal 7 error message looked like this:
PDOException: SQLSTATE[HY000] [2005] Unknown MySQL server host 'foo.bar.123456.hostedresource.com' (2) in drupal_get_installed_schema_version() (line 151 of /my/home/directory/html/includes/install.inc).
While this error message implies that Drupal 7 and PDO can't find the MySQL server, I was able to ping the MySQL server and also connect to it in other ways.
You're pretty locked down at GoDaddy, and even though I have a shell account, and finally was able to see some Apache log messages, I couldn't find an Apache error log or PHP error log.
While many Drupal 7 admin links weren't working because of this Drupal PDOException, I finally got the bright i looked at the Drupal Reports (admin/reports), and looked under the "Recent Log Messages" link, and found my PDOException error message:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'max_filesize' in 'field list': SELECT MAX(max_filesize) FROM {xmlsitemap_sitemap}; Array ( ) in xmlsitemap_requirements() (line 81 of /my/home/directory/html/sites/all/modules/xmlsitemap/xmlsitemap.install).
As you can see, this error message has nothing to do with PDO or MySQL, and has everything to do with the Drupal 7 XML Sitemap module. In my case I disabled and then deleted the XML Sitemap module, and my Drupal 7 PDOException error message went away. This would be really bad if I needed the Sitemap module, but since I have other ways to generate a sitemap, this isn't a really big problem, except for the aggravation.
Lesson learned: Even if you get a Drupal PDOException and MySQL error message displayed on screen, you need to keep digging to find the real error message -- the root cause -- somewhere else. Fortunately I have the Drupal Reports enabled, because if I didn't, GoDaddy would have been no help to me at all here.
Recent blog posts
- Free: Introduction To Functional Programming video training course
- The #1 functional programming (and computer programming) book
- The User Story Mapping Workshop process
- Alvin Alexander, Certified Scrum Product Owner (CSPO)
- Alvin Alexander is now a Certified ScrumMaster (CSM)
- Our “Back To Then” app (for iOS and Android)
- A Docker cheat sheet
- Pushing a Scala 3 JAR/Docker file to Google Cloud Run
- Reading a CSV File Into a Spark RDD (Scala Cookbook recipe)
- Reading a File Into a Spark RDD (Scala Cookbook recipe)