This add-on quickly installs the MS SQL server into a DDEV project. It is based on the mcr.microsoft.com/mssql/server image.
You have to keep in mind that the mssql-docker does not natively work on M1 (arm64). Some workarounds are described in the following threads:
Warning
Due to lack of upstream support, this add-on can only be used with amd64 machines, and is not usable on arm64 machines like Apple Silicon computers.
(You can try installing it on Rosetta using DDEV_IGNORE_ARCH_CHECK=true ddev add-on get ddev/ddev-sqlsrv
)
ddev add-on get ddev/ddev-sqlsrv
ddev restart
After installation, make sure to commit the .ddev
directory to version control.
Command | Description |
---|---|
ddev sqlcmd |
For Transact-SQL statements, system procedures, and script files |
ddev drupal-regex |
For compatibility with Drupal version 9 or higher |
Drupal CMS needs the database function installed that is mimicking the Regex function as Drupal requires. As a one-time setup for Drupal, install the database function by running the following command from your project's directory:
ddev drupal-regex
This script also changes the setting for the following database variables:
show advanced options
will be set to 1clr strict security
will be set to 0clr enable
will be set to 1
Drupal also required the sqlsrv
module to be installed as it is provides the database driver for SQL Server. The module can be installed with composer with the following command:
ddev composer require drupal/sqlsrv
There is an open issue for Drupal 9.4+ installations. Until merged, you need to apply patch #4, see Call to a member function fetchField() on null
This addons disables the default database by automatically adding omit_containers: [db]
in the config.sqlsrv.yaml
If your project needs to use both MariaDB and MS SQL Server databases, you have to remove #ddev-generated
and
omit_containers: [db]
from config.sqlsrv.yaml
.
See Config Options for additional notes.
Use a different port:
ddev dotenv set .ddev/.env.sqlsrv --mssql-external-port=1434
ddev add-on get ddev/ddev-sqlsrv
ddev restart
Make sure to commit the .ddev/.env.sqlsrv
file to version control.
Or change the password:
ddev dotenv set .ddev/.env.sqlsrv --mssql-sa-password='myNewPassword'
ddev add-on get ddev/ddev-sqlsrv
ddev restart
Make sure to commit the .ddev/.env.sqlsrv
file to version control.
All customization options (use with caution):
Variable | Flag | Default |
---|---|---|
MSSQL_DOCKER_IMAGE |
--mssql-docker-image |
mcr.microsoft.com/mssql/server:2022-CU17-ubuntu-22.04 |
MSSQL_EXTERNAL_PORT |
--mssql-external-port |
1433 |
MSSQL_SA_PASSWORD |
--mssql-sa-password |
Password12! |
MSSQL_PID |
--mssql-pid |
Evaluation |
MSSQL_DB_NAME |
--mssql-db-name |
master |
MSSQL_HOST |
--mssql-host |
sqlsrv |
MSSQL_COLLATION |
--mssql-collation |
LATIN1_GENERAL_100_CI_AS_SC_UTF8 |
- SQL Server docker hub
- Installing the ODBC driver for SQL Server
- Installing the ODBC driver for SQL Server Tutorial
- Installation tutorial for MS drivers for PHP
- The SQLCMD utility
- The SQL Server on Linux
- The password policy
- The SQL Server environment variables
- Beakerboy's Drupal Regex database function
- Drupal's module for the SQL Server
- Github MS drivers for PHP
Note that more advanced techniques are discussed in DDEV docs.
Contributed and maintained by @robertoperuzzo based on the original ddev-contrib recipe by drupal-daffie