failed to login to mssql docker database using DBeaver

I have a problem with connection to MSSQL Docker database created from docker-compose.yml file and additional .sql file with ready-to-go empty database configuration. To connect to the MSSQL database i have used DBeaver. During the connection this error occured:

Login failed for user ‘system’. ClientConnectionId:23649321-6526-4ec2-a6ed-9943e64ca019

Probably i have wrong docker-compose.yml file or wrong .sql configuration file (.sql file should work with MSSQL format). .sql file is mounted in scipts folder inside mssql folder with .yml file.

docker-compose.yml file:

version: "3.7"
services:
  sql-server-db:
    container_name: sql-server-db
    image: mcr.microsoft.com/mssql/server:2019-latest
    ports:
      - "1433:1433"
    environment:
        SA_PASSWORD: "secret123new!"
        ACCEPT_EULA: "Y"
        TRUSTED_CONNECTION: "TRUE" 
    volumes:
    - ./data/mssql:/scripts/
    

.sql file:

CREATE DATABASE probna
GO
USE probna
GO
CREATE LOGIN system WITH PASSWORD='system'
GO
CREATE USER system FOR LOGIN system
GO
ALTER ROLE [db_owner] ADD MEMBER system
GO
CREATE TABLE Products (ID int, ProductName nvarchar(max))
GO

If you have any ideas or fixes to existing code in .yml or .sql file please write a comment 🙂
Have a nice day !

Source: Docker Questions

LEAVE A COMMENT