I'm trying to set up a SQL Server on my raspberry with Ubuntu server 20.04. I've followed both a tutorial and the Microsoft documentation and it runs pretty well.
I've finally run this command :
sudo docker run -e 'MSSQL_PID=developer' -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=XXXX' -p 1433:1433 --name azuresqledge -h azuresqledge -d mcr.microsoft.com/azure-sql-edge:latest
I assumed the login would be "developer" and the password "XXX" but it turns out it's not working (Login failed, err n.18456). I tried to access the SQL Server from my computer with SQL Server Management Studio, but it refuses the connection telling me that the credentials are wrong. What can I do?
I also tried with the login "azuresqledge" in doubt, but without result.
Thanks for your help !
The environment variable MSSQL_SA_PASSWORD specifies the password for the sa account. The MSSQL_PID environment value is unrelated an account; it specifies the SQL Server product edition (Developer edition here).
You can provision other accounts after starting the container by connecting with the sa login and executing statements to create logins, database users, etc.. Alternatively, use the SSMS Object Explorer graphical interface for same.
CREATE LOGIN developer WITH PASSWORD = 'password1';
To expand on Dan's answer above which helped me discover the following...
If you need to use a specific login with a password that doesn't meet the requirements, you can turn off the policy like this:
create login admin with password = 'admin', check_policy = off
and if you want it to have sa permissions...
exec master..sp_addsrvrolemember #loginame = 'admin', #rolename = 'sysadmin'
Related
I have a basic Microsoft SQL Server (SQL Server 2017 on Server 2016 Datacenter) in Azure that's currently being power-managed. Every morning I RDP into the VM, enter the SQL Server Management Studio, and reconnect using my local admin account.
The machines automatically reboot, but is there a way to automate the reconnection process?
I reconnect using a GUI interface with the fields:
Server Type: Database Engine
Server Name: hostname
Authentication: Windows Authentication
User name: localadmin
Password:
I then click connect and boom. It seems like there should be a function, something like:
Reconnect-SQLServer -Type DatabaseEngine -Name hostname
-Authentication Windows -Credentials $Credentials
Is there? I haven't been able to find one. Bear with me, I'm fairly new to this sort of stuff.
Edit: It was my impatience. After a short period of time, the database was online and automatically reconnected. The manual process was not needed. Thanks to those who tried to help out.
You can automate connecting sql server management studio with SSMS.exe flags like:
# use current running credentials for windows authentication
SSMS.exe -E -S hostname -d MyDatabase -nosplash
# use specific user account (will prompt for password)
SSMS.exe -U MyUserName -S hostname -d MyDatabase
It kind of sounds like you need something to just end the power-management? It would depend on how that is configured
I'm not familiar with Citrix, but it looks like there is a powershell module for monitoring/managing it and its database connections with cmdlets like Get-BrokerServerStatus for example:
https://support.citrix.com/article/CTX232979/how-to-connect-site-to-sql-ha-sql-mirror-or-a-new-sql-server-after-migrating-your-database
I have my SQLServer 2005 Standard instance configured for mixed mode fine. When using SSMS, none of the sql server logins seem to work. Just "Login failed for user '..'" message. But when I use SQLCMD, it works fine. The behavior is not just for one specific login account. All sql server logins including 'sa' fail when tried via SSMS. Windows logins work fine.
Any ideas?
EDIT1:
When connecting via SQLCMD, I do not specify the -S option. Just the -U and -P
Whereas in SSMS, Server name defaults to the machine name.
In SSMS the server seems to be registered as say xxxxN. When I connect using windows authentication, my ##servername returns xxxx_N.
When I try to use the xxxx_N in SSMS it fails to connect altogether.
Edit2:
When trying via SQLCMD if I give the -S option as xxxxN, it works fine too.
Edit3:
My SQLCMD:
C:...>SQLCMD -U sa -P Password (works)
C:...>SQLCMD -S xxxxN -U sa -P Password (works)
C:...>SQLCMD -U test -P Password (works)
C:...>SQLCMD -S xxxxN -U test -P Password (works)
in SSMS:
ServerType: Database Engine
ServerName: xxxxN
AUthentication: Windows Authentication (works)
ServerType: Database Engine
ServerName: xxxxN
AUthentication: Sql Server Authentication
Login: sa
Password: Password (fail)
ServerType: Database Engine
ServerName: xxxxN
AUthentication: Sql Server Authentication
Login: test
Password: Password (fail)
EDIT 4(Answer)
ODBC connections using sql accounts seem to work fine.
SSMS connections from remote machines work fine also.
This HAS TO BE an issue with local SSMS install. I believe a reinstall would fix this..
Your server/instance name is not consistent between the two.
MyMachineName\Express
is the "most common" instance name.
But yours may vary.
Since sqlcmd "works".
Run sqlcmd, and pass it this command
select [MyServerAndMaybeInstanceName] = ##servername
Then you will know what to put into SSMS ! (ta da!)
EDIT:
You say in sqlcmd, you give it
-U and -P
thus you're using Sql Authentication. (and not windows authentication)
Are you providing Sql Authentication credentials when trying through SSMS ?
I see you said "All sql server logins including 'sa' "
thus you are trying Sql Authentication credentials.
Can you just verify you've tried some Sql Authentication creditials, maybe something besides sa.
EDIT:
Here is a guess, but I hit it one time, a long time ago.
In the SSMS connection box, click "Connection Properties"
Find "Network".
And pick TCP/IP as the network protocol.
especially if the machine is a remote machine.
EDIT:
Here is another poor man's test.
Go to Control Panel /Admin Tools / Data Source (ODBC) / System DSN. And try to add a connection there.
You can also play with the protocols there (named-pipes vs tcp/ip, etc) with the "Client Configuration" button in the Wizard.
I installed an instance of sql server on my machine a while back.
I generally login via SSMS. I currently forgot the username and password for the instance.
Is there a way I can recover it. I searched online including a pervious stack overflow post but didnt
find it helpful. Is there anything I can do to recover my username and password ?
Did you try to Troubleshooting: Connecting to SQL Server When System Administrators Are Locked Out
Start the instance of SQL Server in single-user mode by using either
the -m or -f options. Any member of the computer's local
Administrators group can then connect to the instance of SQL Server as
a member of the sysadmin fixed server role.
And then try to do the following steps as explained by Remus Rusanu in this answer.
shutdown MSSQL$EXPRESS service (or whatever the name of your SQL Express service is)
start add the -m and -f startup parameters (or you can start sqlservr.exe -c -sEXPRESS -m -f from console)
connect to DAC: sqlcmd -E -A -S .\EXPRESS or from SSMS use admin:.\EXPRESS
run create login [machinename\username] from windows to create your Windows login in SQL
run sp_addsrvrolemember 'machinename\username', 'sysadmin'; to make urself sysadmin member
restart service w/o the -m -f
From the system where the server is running, I can login using the following command:
sqlcmd -S "ComputerName\InstanceName" -d "DatabaseName" -i "sql.txt" -s"," -o "result.csv"
I want to connect to this server from another machine, So I tried this
sqlcmd -U "UserName" -S "ComputerName\InstanceName" -d "DatabaseName" -i "sql.txt" -s"," -o "result.csv"
"UserName" above is the default user name of the server machine that has administrative privileges. This user account does not have any password.
After issuing that command, it asks for password. Since there is no password, I hit enter. But I get the following error:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login failed for user 'UserName'..
SQLCMD Reference
i met this situation:
sqlcmd -S "server" -d "db" -E -i test.sql
which gives "Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login failed for user 'DOMAIN\administrator'.."
but when i switched to:
sqlcmd -S server -d db -E -i test.sql
it works fine. so look out for your double quotes. hope this maybe of help.
-U UserName specifies the name of a SQL Server login, not a Windows user. It seems to me you want to use a Windows user. The proper way to do it is to have a domain, run as a domain user and grant appropriate permissions in SQL to domain group of which you are member. Bare that, you can use runas /netonly /user:ComputerName\UserName sqlcmd -E.
The issue is related to differences between SQL and windows authentication.
In case of windows authentication e.g. in domain environment with several untrusted domains it is only option to use runas.exe /netonly /user:YourTargetDomain\SQLUser to run SQLCMD or Ssms.exe (SQL management studio) under the proper SQL User.
Both sqlcmd and ssms can use Windows (also domain) authentication without any credentials SQLCMD -E (UI option in Studio) but process should be run as a local or domain user configured for NT Authentification in SQL. Or provide SQL user credentials (configured directly on SQL server e.g. SA) - SQLCMD -U SQLUserName -P SQLUserPassword (the second UI option in the Studio).
Commands below can be used to connect to SQL server configured with Windows (NT) authentication (e.g. lab domain user) from machine in separate untrusted domain (e.g. from office laptop with your office domain account - not configured to access the SQL server).
To run SSMS (it is possible to create a windows desktop shortcut, path to ssms can be different, depends on used version and installation preferences):
C:\Windows\System32\runas.exe /netonly /user:MyLabDomain\SqlUser "C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe
To run a query with SQLCMD (in the example, it cleans a table, also can be used as a shortcut):
C:\Windows\System32\runas.exe /netonly /user:MyLabDomain\SqlUser "sqlcmd -S 123.123.12.34 -E -I -Q \"delete FROM TestDB..TestTableToEmpty\""
SSMS or SQLCMD should be installed on machine from which you connect to SQL server.
After run you should enter passwords for the SQL User.
I suppose, these examples may help somebody.
I have installed SQL Server 2008 express and logging in through windows authentication, it doesn't allow me to do anything. How do i change 'sa' password or gain full privilege in my local computers 2008 express ? I am using windows 7.
If you want to change your 'sa' password with SQL Server Management Studio, here are the steps:
Login using Windows Authentication and ".\SQLExpress" as Server Name
Change server authentication mode - Right click on root, choose Properties, from Security tab select "SQL Server and Windows Authentication mode", click OK
Set sa password - Navigate to Security > Logins > sa, right click on it, choose Properties, from General tab set the Password (don't close the window)
Grant permission - Go to Status tab, make sure the Grant and Enabled radiobuttons are chosen, click OK
Restart SQLEXPRESS service from your local services (Window+R > services.msc)
You need to follow the steps described in Troubleshooting: Connecting to SQL Server When System Administrators Are Locked Out and add your own Windows user as a member of sysadmin:
shutdown MSSQL$EXPRESS service (or whatever the name of your SQL Express service is)
start add the -m and -f startup parameters (or you can start sqlservr.exe -c -sEXPRESS -m -f from console)
connect to DAC: sqlcmd -E -A -S .\EXPRESS or from SSMS use admin:.\EXPRESS
run create login [machinename\username] from windows to create your Windows login in SQL
run sp_addsrvrolemember 'machinename\username', 'sysadmin'; to make urself sysadmin member
restart service w/o the -m -f
I didn't know the existing sa password so this is what I did:
Open Services in Control Panel
Find the "SQL Server (SQLEXPRESS)" entry and select properties
Stop the service
Enter "-m" at the beginning of the "Start parameters" fields. If there are other parameters there already add a semi-colon after -m;
Start the service
Open a Command Prompt
Enter the command:
osql -S YourPcName\SQLEXPRESS -E
(change YourPcName to whatever your PC is called).
At the prompt type the following commands:
alter login sa enable
go
sp_password NULL,'new_password','sa'
go
quit
Stop the "SQL Server (SQLEXPRESS)" service
Remove the "-m" from the Start parameters field
Start the service
This may help you to reset your sa password for SQL 2008 and 2012
EXEC sp_password NULL, 'yourpassword', 'sa'
This is what worked for me:
Close all Sql Server referencing apps.
Open Services in Control Panel.
Find the "SQL Server (SQLEXPRESS)" entry and select properties.
Stop the service (all Sql Server services).
Enter "-m" at the Start parameters" fields.
Start the service (click on Start button on General Tab).
Open a Command Prompt (right click, Run as administrator if needed).
Enter the command:
osql -S localhost\SQLEXPRESS -E
(or change localhost to whatever your PC is called).
At the prompt type the following commands:
CREATE LOGIN my_Login_here WITH PASSWORD = 'my_Password_here'
go
sp_addsrvrolemember 'my_Login_here', 'sysadmin'
go
quit
Stop the "SQL Server (SQLEXPRESS)" service.
Remove the "-m" from the Start parameters field (if still there).
Start the service.
In Management Studio, use the login and password you just created.
This should give it admin permission.