프로그래밍/PHP

[PHP] mysql_connect(): Headers and client library minor version mismatch.

채윤아빠 2016. 10. 25. 12:42
728x90
반응형



문제점 및 증상

  • ubuntu + apache2 + php5 + MariaDB 개발환경에서 "mysql_connect(): Headers and client library minor version mismatch." 경고 발생

원인 분석

  • 구글링결과 php5에 설치된 MariaDB 연결 클라이언트의 버전이 달라서 발생한 문제임
  • php5-mysql 모듈을 제거하고, php5-mysqlnd를 설치하면 해결됨

작업 내용

  • PHP5 Client API 확인
    root@devdb:~# php -i | grep 'Client API'
    Client API version => 10.1.14-MariaDB
    Client API library version => 10.1.14-MariaDB
    Client API header version => 5.5.49
    Client API version => 10.1.14-MariaDB
    
  • php5-mysql 제거
    root@devdb:~# apt-get remove php5-mysql
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages will be REMOVED:
      php5-mysql
    0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
    After this operation, 297 kB disk space will be freed.
    Do you want to continue? [Y/n]
    (Reading database ... 79591 files and directories currently installed.)
    Removing php5-mysql (5.5.9+dfsg-1ubuntu4.17) ...
    php5_invoke prerm: Disable module mysql for cli SAPI
    php5_invoke prerm: Disable module mysql for apache2 SAPI
    php5_invoke prerm: Disable module mysqli for cli SAPI
    php5_invoke prerm: Disable module mysqli for apache2 SAPI
    php5_invoke prerm: Disable module pdo_mysql for cli SAPI
    php5_invoke prerm: Disable module pdo_mysql for apache2 SAPI
    Processing triggers for libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.17) ...
    
  • php5-mysqlnd 설치
    root@devdb:~# apt-get update
    root@devdb:~# apt-get install php5-mysqlnd
    
  • apache2 서비스 재시작
    service apache2 restart
    

참고 자료