MSSQL server with Docker
https://database.guide/how-to-install-sql-server-on-a-mac/
get docker container
sudo docker pull microsoft/mssql-server-linux:latest
create docker container
password needs
Uppercase letters, Lowercase letters, Base 10 digits, and Symbols..
docker run -e'ACCEPT_EULA=Y' -e'MSSQL_SA_PASSWORD=YourPassword123!' -p 1433:1433 --name sqlserver -d microsoft/mssql-server-linux
start docker container
docker exec -it sqlserver bash
run as SA
/opt/mssql-tools/bin/sqlcmd -U SA
view password (!)
echo $MSSQL_SA_PASSWORD
change password:
docker exec -it sqlserver2 /opt/mssql-tools/bin/sqlcmd -U SA'Root123!' -Q'ALTER LOGIN SA WITH PASSWORD="YourPassword123!"'
download
mssql datastudio
create and save data in volume
docker run -e'ACCEPT_EULA=Y' -e'MSSQL_SA_PASSWORD=YourPassword123!' -p 1433:1433 --name sqlserver2 -v sqlservervolume:/var/opt/mssql -d microsoft/mssql-server-linux
to see volumes
docker volume ls
backup external to local desktop...
docker cp newsqlserver:/var/opt/mssql ~/Desktop
copy into container
docker cp ~/Desktop/filetocopy.ext newsqlserver:/
backup from within the mssql in new backup folder
/opt/mssql-tools/bin/sqlcmd -U SA //get in db
1> BACKUP DATABASE Products TO DISK ='/var/opt/mssql/backup/Products.bak'
2> GO
exit
copy it to desired location...
code first approach:
dotnet ef migrations add InitialMigration
dotnet ef database update
sql operations studio:
no longer in active development...
azure datastudio:
same as sql operations studio...
https://docs.microsoft.com/en-us/sql/azure-data-studio/download?view=sql...
in azure datastudio:
new query
IF NOT EXISTS (
SELECT name
FROM sys.databases
WHERE name = N'TutorialDB'
)
CREATE DATABASE [TutorialDB]
GO
ALTER DATABASE [TutorialDB] SET QUERY_STORE=ON
GO