I have a Laravel web application running on a Nginx application server. The application has 2 database connections: one to a local MySQL database named picking_demo and another to a remote Microsoft SQL Server named db_picking_main.
The MySQL connection works fine and doesn't need to be changed.
At first, the application worked under Laravel 5 and PHP 7. For the SQL Server connection, the application used the library techscope/laravel-sqlserver and it worked well.
However, due to client's requirements, we had to migrate the application to the latest Laravel and PHP Versions (version 8 for each) and we must use Ubuntu as the operative system. Thus, techscope/laravel-sqlserver is not compatible anymore and it had to be deleted from composer.json.
We are currently using the 20.04 version of Ubuntu.
At first, when we tested the connection from one of the application's commands that must work with the SQL Server connection, we got a "Driver not found" error.
After some research, I installed the following packages from the repositories: freetds-common, freetds-bin, php8.0-pdo-sybase. The package unixodbc was already installed when we started to work.
Also, I installed the ODBC Driver 17 for SQL Server following Microsoft's official instructions (see https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15)
Afterwards, I tried executing the applicacion's command again and it gave me the following message:
In Connection.php line 685:
SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (10.0.50.8:1433) (severity 9) (SQL: sel
ect count(*) as aggregate from [deli_eti_correl] where [correl] > 1234891)
In Connector.php line 70:
SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (10.0.50.8:1433) (severity 9)
This is the content in config/database.php:
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'geostore'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'options' => [
\PDO::ATTR_PERSISTENT => true
]
],
'todosport_dummy' => [
'driver' => 'mysql',
'host' => 'localhost',
'port' => '3306',
'database' => 'todosport_dummy',
'username' => 'root',
'password' => '',
'unix_socket' => '',
'charset' => 'utf8',
'collation' => 'utf8_spanish2_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'options' => [
\PDO::ATTR_PERSISTENT => true
]
],
'delisur_picking' => [
'driver' => 'sqlsrv',
'odbc_driver' => '{ODBC Driver 17 for SQL Server}',
'host' => '10.0.50.8',
'database' => 'bd_delisur_main',
'username' => 'sa',
'password' => 'Latorredebabel6427....D',
'port' => '1433',
'prefix' => '',
'charset' => 'utf8',
'collation' => 'utf8_spanish2_ci',
'TrustServerCertificate' => 'no',
'options' => [
\PDO::ATTR_PERSISTENT => true,
"MultipleActiveResultSets"=>'0',
"ConnectionPooling" => "1",
"TraceOn" => "0",
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
]
]
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
];
Questions:
- Must I still configure TDS in order to connect to the desired database? If not, what steps are missing?
- Is it possible that the cause is a permissions issue from the SQL Server Database server?
Thanks in advance
Adaptive Server is unavailable or does not existdoesn't sound like a permission issue. Looks like Laravel can't find your database. Triple check your databse configuration in your .env file.tsql -H Host -U Username -D DatabaseName -p 1433 -P Password) with no avail. But the credentials are already recognized in config/database.php. Laravel would give me a different error message if otherwise.