I deployed sql server 2017 to my kubernetes and I want to put it a sample db such as northwind. There is no a gui for manage sql server. How Can I do that?
You can forward your sql server port to localhost and then connect to the database using SQL Server Management Studio.
kubectl port-forward <sql-pod-name> <localhost-port>:<mssql-port>
For example:
kubectl port-forward mssql-statefulset-0 1433:1433
Then your database would be accessed on localhost.
Note that there is a comma between the address and the port.
If you manage to connect successfully, you can manually create the database using the SQL Server Management Studio tool.
Another way is to connect directly to your database container inside a pod using exec command and then execute sqlcmd commands.
kubectl exec -it <pod-name> -- /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'SA-password'
Or just like this
kubectl exec -it <pod-name> -- /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'SA-password' -Q 'CREATE DATABASE <database-name>'
Cannot connect to mssql localhost instance via Azure Data Studio. Get: 'login failed for user sa'.
In the same time I'm able to successfully connect via terminal: mssql -u sa -p myPassword
mssql is in docker with status up
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=myPassword" -p 1433:1433 --name sql1 -h sql1 -d mcr.microsoft.com/mssql/server:2019-latest
os: ubuntu 20.04
firewal is off
I'm sure that pwd is correct, as I can connect to mssql via terminal. Is it Azure settings? Or ubuntu?
Thank you in advance!
I was able to connect to sql instance via Azure Data Studio after change the password. I was using special characters (#, #, $) that might have caused the problem.
After altering password that doesnt iclude special characters it starts working!
I'm able to run a SQL Server (for linux) instance in playwith docker
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Password_01!" -p 1433:1433 --name sql1 --hostname ciccio -d microsoft/mssql-server-linux:2017-latest
and issue some commands from the terminal
docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S ciccio -U sa -P Password_01!
However, I can't to connect to this instance from my local Management Studio.
Does anyone know how to do this? What check to see if the ports are open or the connection is reachable?
I've tried with the following address combinations:
http://ip172-18-0-43-bkarle1t0o8g00cjuvdg-1433.direct.labs.play-with-docker.com
http://ip172-18-0-43-bkarle1t0o8g00cjuvdg-1433.direct.labs.play-with-docker.com,1433
ip172-18-0-43-bkarle1t0o8g00cjuvdg-1433.direct.labs.play-with-docker.com
ip172-18-0-43-bkarle1t0o8g00cjuvdg-1433.direct.labs.play-with-docker.com,1433
the ip172-18-0-43-bkarle1t0o8g00cjuvdg-1433.direct.labs.play-with-docker.com are the urls provided from playwithdocker when the service is up and running
I have a problem followng [this tutorial](https://hub.docker.com/r/microsoft/mssql-server-linux/
) where I try to connect to my docker hosted MSSQL via sqlcmd.
I executed the following in PowerShell from windows:
docker run -e 'ACCEPT_EULA=Y' --name mssql -e \
'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -it \
-d microsoft/mssql-server-linux:latest /bin/bash
Note: "-it" and "/bin/bash" is added due to docker will be stopped automatically if there is no any activity detected.
I ran docker container ls -a to verify it is running:
docker container Is -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92cfc504ab70 microsoft/mssql-server-linux:latest "/bin/bash" 27 minutes ago Up 27 minutes 0.0.0.0:1433->1433/tcp mssql
I ran telnet local-ip:1433 on my host, it is working fine.
Problem lies when I do the following:
docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa \
-P yourStrong(!)Password
Error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout
expired. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP
Provider: Error code 0x2749. Sqlcmd: Error: Microsoft ODBC Driver 17
for SQL Server : A network-related or instance-specific error has
occurred while establishing a connection to SQL Server. Server is not
found or not accessible. Check if instance name is correct and if SQL
Server is configured to allow remote connections. For more information
see SQL Server Books Online..
I also tried to connect in using powershell via my host
Link:https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker
Command:
sqlcmd -S 192.168.0.110,1433 -U SA -P yourStrong(!)Password
Note: 192.168.0.110(got this from running ipconfig in host machine.)
Any help ?
I found out the problems after some trials and errors, and re-reading the documents. I should use double quotes for the arguments when I executed my command in PowerShell.
I was looking into the wrong direction. Initially I executed the command:
docker run -e 'ACCEPT_EULA=Y' --name mssql -e \
'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d \
microsoft/mssql-server-linux:latest
Container stopped automatically by itself every time it starts.
Then, I did some googling and found:
docker run -e 'ACCEPT_EULA=Y' --name mssql -e \
'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -it -d \
microsoft/mssql-server-linux:latest /bin/bash
It seemed fine on the surface. It got executed successfully in PowerShell. It didn't stop automatically anymore.If I dig deeper using
docker container logs mssql
to see the log for mssql. No error given, just that I don't see a lots of info given, which led me to think that there were no problems in my command.
But the right way to run these commands is using double quotes.
Link: https://hub.docker.com/r/microsoft/mssql-server-linux/
IMPORTANT NOTE: If you are using PowerShell on Windows to run these commands use double quotes instead of single quotes.
E.g.
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" -p 1401:1433 --name sql1 -d microsoft/mssql-server-linux:2017-latest
I am also able to login using SSMS with:
Server name: Hostip,1401
Username: sa
Password:yourpassword
Try 127.0.0.1 or 0.0.0.0 instead of localhost
For example :
docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P 'yourStrong(!)Password'
docker run command syntax is the following:
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
When you execute the command:
docker run -e 'ACCEPT_EULA=Y' --name mssql -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -it -d microsoft/mssql-server-linux:latest /bin/bash
/bin/bash in the end overrides CMD layer defined in the Dockerfile of microsoft/mssql-server-linux image.
So, just start a container without any additional command in the end:
$ docker run -e 'ACCEPT_EULA=Y' --name mssql -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -it -d microsoft/mssql-server-linux:latest
And now you are able to access a MSSQL:
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'yourStrong(!)Password'
1>
I'm new to Docker and I also I had the same issue when I try to connect to the SQL Server container from my application(or sqlcmd app container from Microsoft) which is also running in another Docker container. It looks like each container gets its own subnet IP address, so 'localhost' would never work if you're trying to connect to the SQL from another container.
The command below will give you the full list of IP addresses in the bridge network. You can specify the IP directly in the connection string.
docker network inspect bridge
From your message, it looks the server is not configured to access remotely. Can you follow the way mentioned below to enable it?
Using SSMS (SQL Server Management studio):
In Object Explorer, right-click a server and select Properties.
Click the Connections node.
Under Remote server connections, select the Allow remote connections to this server check box.
Thanks,
Ananda Kumar J.
I am trying to run a docker container from the Microsoft SQL Server Express image (https://hub.docker.com/r/microsoft/mssql-server-windows-express/)
For example I've tried the following commands (I'll use the -d flag once I've got it working)
docker run -it -p 1433:1433 -e SA_PASSWORD=Mfp_4871nJUj_1-23H -e ACCEPT_EULA=Y --name to_delete_1 microsoft/mssql-server-windows-express powershell.exe
docker run -it -p 1433:1433 -e 'SA_PASSWORD=Mfp_4871nJUj_1-23H' -e 'ACCEPT_EULA=Y' --name to_delete_1 microsoft/mssql-server-windows-express powershell.exe
(not the real password - I've tried many passwords since one of the suggestions for fixing the error I see below is to ensure that the password meets Microsoft's password policy. However for all passwords I get the same error)
I've also tried lower case sa_password
However, each time I try to connect with the sa account from within the container using any of
sqlcmd -U sa -P Mfp_4871nJUj_1-23H
sqlcmd -S localhost -U sa -P Mfp_4871nJUj_1-23H
sqlcmd -S localhost\sqlexpress -U sa -P Mfp_4871nJUj_1-23H
sqlcmd -U sa
sqlcmd -S localhost -U sa
sqlcmd -S localhost\sqlexpress -U sa
(entering password for last 3)
I get
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user 'sa'..
Looking at the SQL Server logs it shows
2017-03-13 21:25:52.32 Logon Error: 18456, Severity: 14, State: 7.
2017-03-13 21:25:52.32 Logon Login failed for user 'sa'. Reason: An error occurred while evaluating the password. [CLIENT: 172.22.251.6]
The main advice is to ensure the password meets SQL Server's password criteria but I think all of the passwords I've tried do.
I run Docker on Windows 10 Enterprise (build 14393.693).
I have Docker for Windows Version 17.03.0-ce-win1 (10300).
What do I need to do to be able to connect to SQL Server from within the container using the microsoft/mssql-server-windows-express Docker imamge?
Thanks
I don't know if you ever found the answer to this question. I have not tried connecting to the database from within the container, but I have connected to it from SSMS from outside the container. The key for me was to specify the password in double quotes in the original command. The final command looked like this:
docker run -d -p 1433:1433 -e sa_password="useComplexPasswordHere" -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express
I was then able to connect to it through SSMS. Get the IP address from the docker container using:
docker inspect
Then log in to the database through SSMS like this:
SSMS Login info