Get SQL Server database server address - sql-server

I am installing an app and I am at the point where I am supposed to provide the server details. I installed SQL Server Express and I also installed SQL Server Management Studio.
This is the screenshot:
I did execute this command
select ##servername
but I got this response:
I am running this on my local machine. How can I find the database server address and also the server password?.
PS: I do not remember setting any password when installing SQL Server.
Thanks.

When you executed the command select ##servername, how were you connected to the server? Running that command required knowing the servername and authentication of some kind. I'm guessing you were connected to DESKTOP-KOJLCIF\SQLEXPRESS or .\SQLEXPRESS using windows authentication.
When you installed SQL Express, there was an option for Windows Authentication or SQL Server + Windows (aka Mixed Mode) Authentication. If you chose Windows Authentication (which is the default if I recall), you will not have SQL Server usernames or passwords.
The app you are installing appears to required SQL Auth, so you need to pick Mixed Mode in your setup (which allows both Windows Auth and SQL Auth). You can find this setting in recent versions of SQL Server Management Studio by right-clicking your database server in object explorer, going to Properties, and then looking at the Security page. Older versions of SQL require going to another tool included in the installation folders-- server configuration or some such, the name escapes me. Change the authentication to "SQL Server and Windows Authentication mode". I believe a SQL Server restart is required after doing this.
You can then create SQL logins with username and passwords and appropriate permissions using the GUI in SSMS (expand security folder under your server and look at the logins sub folder) or via CREATE LOGIN t-sql command.
There is a fixed sql login called 'sa' that will always exist if SQL Auth is enabled. You could right click this login, go to properties, and change the password. Be careful giving out your sa credentials to an app, as that can control the entire server.

Related

Windows Authentication Failed on changing the domain server

I had installed SQL server 2012 using windows authentication and attached a database that is on my C drive. Domain server failed and we have to rebuild domain server. The domain server name is now changed to new name. When I try to log in to the SQL 2012 Studio, I can not log in and I am getting an error login failed for the user.
All we did was add a letter to the domain server. Could someone direct how to correct the issue as SQL server 2012 studio is not allow me to login?
Thanking you,
Hem
This is about more than just changing the name. Domain memberships involve cyrptographic signatures that must also be replaced. All of the machines in your domain will need to re-join. You'll have a new account on your own machine. Yep, it sucks, and this is one reason why you should always keep at least 2 DCs.
Assuming you don't know any other account info, the only way to get back into the existing Sql Server instance is to restart Sql Server in single-user mode and connect as a local administrator. After you've done this, you'll need to recreate all of your logins.
Since you'll be recreating accounts and permission anyway, another option is to use this as opportunity to upgrade to a more recent Sql Server version. Sql Server 2012 is already major 3 releases behind. Shut down and uninstall the existing Sql Server instance. Install the new version of the Sql Server, where you know the sa login, and then attach to the old database mdf files.
Have you try to login with SQL authentication? (with SA account)
SQL:
DROP LOGIN [OldDomain\UserName]
GO
CREATE LOGIN [NewDomain\UserName] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [NewDomain\UserName]
GO
Then you will be able to login with your new domain name. (Make sure you change the domain name and username in the above SQL)
If you need to recover your sa password? Check this article How to recover SA password

SQL Server 2012 Express login failed from client machine

I have installed SQL Server 2012 Express edition on a pc which is on a workgroup running Windows 10. I have also created an user for access to the database through the VS2013 application.
When trying to connect to the server from the client machine, I am getting a message saying login failed and it is from an untrusted domain. The client is also on the same workgroup. However, after the SQL Express was installed on the "server" machine, the name of that pc was changed. I can connect to the database from the server using SSMS using the new computer name (in the instance). I have set remote connection parameters and also configured firewall rules. Yet I am unable to access the server from the client machine.
I also want to ensure that the database is totally secured against access or intrusion. Anyone having access to the server machine can view/edit the database using Windows Authentication. How best to safeguard against it?
Any tips would be appreciated.
CL
try to make a new user in server machin using SSMS and be sure that you are adding the new user to the Login Part of Security in SSMS . For this you need to Login to SSMS as administrator ...

Capture Azure VM Image with SQL Server

I have followed these steps https://www.windowsazure.com/en-us/manage/windows/how-to-guides/capture-an-image/ to capture an image of a VM. Used sysprep as mentioned and I was able to replicate the VM. The problem is that when I rdp into the machine, I can't connect to SLQ Server. Login fails for Windows Authentication. Usually this means that the SQL Server is on another domain, but in this case the error is on local machine.
So my question is, how to capture an image of a VM with SQL Server in Windows Azure and ensure that I can login with Windows Authentication at least when deployed?
I don't think you can, I think you will need SQL Server Authentication before sysprep (I haven't tested this), as far as I know this is the same on-premises and not an Azure feature per se...
If you run sysprep on Windows, you shouldn't have any expectations that the current principals provisioned in SQL Server will continue to work. SQL Servers references Windows accounts by their SIDs and running sysprep on Windows will create a new set of SIDs for the Windows account. Therefore, you will have to re-add them to SQL Server as you've discovered.
Adding a solution that worked for me, in case anyone facing same problem and haven't found any working solution.
After creating an Azure VM from the Image based on a generalized VM (sysprep run):
Launch SQL Server Configuration Manager.
Navigate to SQL Server Services.
Right click on SQL Server (SQLEXPRESS)->Properties from the right side panel.
Select 'This account:' and enter details of current VM Administrator credentials.
Apply changes and restart SQL Server.
Now, try connecting to the SQL Server. It should work.

Cannot connect to "local" (SQL Server 2008)

I have some database problems.
I have SQL Server Developer installed on my local machine. When I open SQL Server Management Studio and log in with windows authentication there is no problem. I have created a new database there and added a new user. The new user is owner of the database.
When I disconnect from my windows session and try to log in with the newly created user in SQL Server authentication mode I get the 'cannot connect to (local)'
Please help!
Have you enabled SQL Server authentication? (During installation and/or afterwards)
If not, connect using windows authentication, right-click on the server instance, go to properties and change auth mode...

Amazon EC2 Instance - How to find SQL Server Password

I have created an Amazon EC2 Instance that provides Windows Server 2008 with SQL Sever 2008 pre-installed. Now in order to use the SQL Server for creating databases, or restoring backups of the databases that I have on my local machine, I need the "sa" password for SQL Server 2008.
I have tried using the following but with no luck:
sa
password
"blank password"
"same password as the admin password for my EC2 instance"
Could someone please guide me as to how to get started with using the Amazon EC2 Datacenter with respect to the "sa" password.
Thanks
A bit of an update as of 2010-07-01, using a fresh Amazon image of Windows 2008 Datacenter (with SQL Server Express), SQL server was running, but the sa account was neither enabled nor with a known password. Follow these steps to fix it:
Use SQL Server Management Studio to connect to your data base server using Windows Authentication (Administrator user, for instance).
Expand the Security and Logins groups.
Open the sa account.
On the default screen ("General") set a new Password as you see fit.
Select the "Status" screen on the left.
Set the "Login:" option to "Enabled".
Click the OK button.
Right-click the root node (this will name your SQL server) and select Properties.
Select the "Security" screen on the left.
Set "Server authentication" to "SQL Server and Windows Authentication mode"
Restart the SQL Server service.
Enjoy your new-found sa access! (finally)
On a fresh Amazon EC2 "small" instance, as of 2010-05-31, the SQL services are disabled by default.
Fix: Enable any service starting with "SQL".
"Start..Administrator Tools..Services".
Select every service starting with "SQL", set the startup type to "Automatic".
Start every service starting with "SQL".
Some services will refuse to start, don't worry about this.
Now, you can go back into "SQL Server Management Studio", and everything will work nicely.
Update
2010-05-31. I tested the instructions above, with a fresh Amazon EC2 instance with SQL Server installed, and everything worked just as I described.
Update
2010-10-07. The real reason Amazon EC2 disables SQL Server, by default, on a small instance is that it doesn't actually have enough RAM to run things properly. I'm not even sure why they installed it in the first place. From bitter experience, I'd recommend that you run MySQL, given the choice, as its faster and lighter, or upgrade to a decent sized instance.
Update
Another reason why SQL is disabled, by default:
I'm pretty sure they they want to avoid being "that" company that lets loose another
"code red" or "sql slammer" worm - #Dan Esparza
RDC to the server under Administrator and connect to MSSQL instance using Enterprise Studio, using trusted connection. Then go to Security and set sa password to what you need it to be.
The short answer for how to get into SQL Server is you must RDP to the server using the Administrator account for that server (not a domain admin) and then connect to SQL using Windows Authentication. From there, you can then enable sa or add any other accounts.
When running the Microsoft SQL Server Management Studio, make sure you run it as administrator even if you have administration rights.
You could not view the password directly as it would be present under syslogins in an encrypted format.
But, You can reset the pwd.
Login to SSMS with "Windows Authentication" --> Expand "Security--> Logins"
Under "Logins", Select the appropriate LoginName and open the properties window. There you can Provide a new Password to your login.

Resources