How to install sqlserver driver for php71 on OSX?

This is the answer to "How to install sqlserver driver for php71 on OSX?".

1. Install pear && pecl

curl -O http://pear.php.net/go-pear.phar  
sudo php -d detect_unicode=0 go-pear.phar
  • type 1, return, enter "/usr/local/pear"
  • type 4 , return, enter "/usr/local/bin"
  • return

check pear with:

pear version

2. Install pear && pecl

sudo pecl install sqlsrv pdo_sqlsrv 
sudo echo "extension=pdo_sqlsrv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
sudo echo "extension=sqlsrv.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

3. Install OBDC

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install --no-sandbox msodbcsql mssql-tools

if error: odbcinst: SQLRemoveDriver failed with Unable to find component name.

check:

1.) whether the file odbcinst.ini is existed under the folder /usr/local/Cellar/unixodbc/2.3.4/etc/

2.) if it exists, list out the contents of this file: cat /usr/local/Cellar/unixodbc/2.3.4/etc/odbcinst.ini

3.) list out the permission of the file: ls -l /usr/local/Cellar/unixodbc/2.3.4/etc

4.) check if you can see the error 'odbcinst: SQLRemoveDriver failed with General installer error' by running the command in a terminal window: odbcinst -u -d -n "ODBC Driver 13 for SQL Server"

5.) see if you can run the command successfully if you prefix the command with sudo in the terminal window: sudo odbcinst -u -d -n "ODBC Driver 13 for SQL Server"

6.) if it runs without the error, brew doesn't have write permission for the file odbcinst.ini. It shouldn't need sudo to modify the file.

results for ""

    No results matching ""