CLI命令模式下Call to undefined function mysql_connect()

背景:
php

    http訪問一切正常,能夠connect到數據庫存取數據。可是當CLI模式時會出現Call to undefined function mysql_connect() mysql



緣由:CLI模式下 沒有配置php.ini文件,或者配置了php.ini,可是php.ini裏沒有php_mysql.dll或mysql.so模塊sql



解決:數據庫

1 首先執行 php -m檢查 mysql模塊是否加載
ide


2 執行命令 php --ini 檢查命令模式的配置文件路徑以及配置文件是否存在spa

輸出以下:ci

Configuration File (php.ini) Path: /usr/local/lib

Loaded Configuration File:         (none)

Scan for additional .ini files in: (none)

Additional .ini files parsed:      (none)


能夠看到配置路徑和配置文件爲空,則須要在改路徑下存放php.ini文件,而後在php.ini裏配置php_mysql.dll或mysql.so模塊it



一切OK,解決io

相關文章
相關標籤/搜索