3

I spent some hours trying to solve a migration from CentOS 5.5 to 7 in which everything worked except PHP-based sites connecting to the MySQL server for a Web site. Perl worked fine. CLI commands worked fine. I tried every solution listed on Stack Overflow and elsewhere:

  • Make sure /etc/hosts contains localhost as the first entry for 127.0.0.1
  • Check that PHP is correctly pointing to the right socket
  • Try swapping localhost and 127.0.0.1 in the connection setup
  • Checked php.ini for any settings that differed between my functional CentOS 5.5 setup and the new stock CentOS 7 installation.

Annoyingly, I couldn't get PHP to dump errors, whether via Apache or elsewhere. It was all maddening.

  • Nice what you are doing but the solution should come as an answer. Please, try separating the question and then write the solution in the answer section. That way this won't come up unresolved... – FirstOne Dec 24 '15 at 19:21
  • Thanks! Fixed into that Q/A pair. – GlennFleishman Dec 24 '15 at 22:33

1 Answers1

3

After checking for the fifth time that I had the right drivers installed, I realized that there are two CentOS/yum packages: one is php-mysql; the other is php-mysqlnd, a native driver.

Uninstalling php-mysql, which is apparently outdated, but which is what I used in CentOS 5.5, and installed php-mysqlnd instantly fixed the problem.

I have been unable to find any other answers of this sort, so perhaps my situation is unique. But I wanted to document it in case someone else came across the same migration issue.