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
- Business Analyst: How to write accurate software requirements
- Business Analyst: A simple secret to running a great meeting
- One thing a business analyst should ask about any requirement
- Business Analysts and Use Case quality: Questions to ask yourself when writing a Use Case
- The three things a Business Analyst should think about during meetings
- Testing web applications Selenium with Scala 3 and ScalaTest
- Scala Cookbook 2021: A best-selling new release in OOP and FP
- Salar Rahmanian's newsletter (and Functional Programming, Simplified)
- Our “Back To Now” app: Now available on iOS and Android
- An Android location “Fused Location Provider API” example