简体   繁体   中英

Connect to SQL Server in PHP 7.2 on Ubuntu 16.04, using Microsoft Drivers for PHP for SQL Server, works in browser but fails in command-line

I'm trying connecting a remote SQL Server database and getting its data for writting to my local Mysql database on Ubuntu. I've been using Microsoft Drivers for PHP for SQL Server (ODBC driver installed) and it works in the browsers.

But while I run it in command-line, it shows could not find driver , just like the Driver is never installed.

My environment:

  1. Ubuntu 16.04.5
  2. PHP 7.0.32
  3. Apache 2.4.18
  4. MySQL 5.7.24

The remote server is Windows Server 2012 with SQL Server 14.0.1000.

I've configured my Apache and PHP correctly followed the official tutorial (otherwise it probably could not work even in the browser), so I don't know why it doesn't work in the command-line or terminal. Please help, thanks.

You have to enable this driver in the CLI php.ini file.

To find this file, open a console and type php --ini , this will show you the path of the current php CLI ini file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM