Related
I am really tired, it's been 3 days that I can't open my SQL Server Management Studio. I got connection string error with number 87. Below screenshot show my problem:
And I use localhost\MSSQLSERVER with error 87 and Arash-PC (my machine name) with error number 2.
And I tried sqlcmd -U sa -S Arash-PC too
You need to check in your SQL Server Configuration Manager what services and instances you have installed. Go to Start Menu > All Programs > Microsoft SQL Server (version) > Configuration Tools and launch the appropriate Configuration Manager. You should see a screen something like this:
Find the SQL Server (.....) service(s), and make sure the service is started.
If you find a SQL Server (MSSQLSERVER) service started, then you have a (unnamed) default instance to which you can connect using
.
(local)
Arash-PC
You MUST NOT supply the MSSQLSERVER as the instance name!
If you find any other SQL Server (instance name) service started (e.g. SQL Server (SQLEXPRESS) in my screenshot), then the instance name (SQLEXPRESS) needs to be appended to the server name to connect to that instance:
.\SQLEXPRESS
(local)\SQLEXPRESS
Arash-PC\SQLEXPRESS
Make sure you are not running out of space on the drive where SQL is installed. Try rebooting as well.
Verify that the SQL Server (MSSQLSERVER) service is started. Click Start, click Administrative Tools, click Services, and scroll to SQL Server (MSSQLSERVER). If it is not started, right-click the service, select Properties, in Startup Type select Automatic, click Apply, click Start, and then click OK. Make sure service started. If service did not start - you need to analyze event log. Alternatively - try reinstalling/repairing SQL server.
Make sure you have no network problems - try temporary disabling any firewalls(including Windows Firewall) and antiviruses.
If service is started and firewalls disabled but still no luck - time to check SQL Server Configuration Manager settings. In detail it is described here and here. Shortly I would recommend first enable all protocols in both server and client sections. Reboot. Check it works. If that would not help - then try disabling everything apart from TCP/IP (both server and client sections). Reboot again.
If above does not help - try reinstalling SQL Server. Just make sure you have saved your databases 1st. To save them - stop sql server service, and copy your *.mdf and *.ldf (from SQL server Data folder) files to safe location. Later on you can attach them. If you are not sure where your SQL server Data folder located - just search for files with mdf extension.
Edit:
Successful telnet showing SQL server port is up looks this way:
Edit2:
Launch Event Viewer:
Click System, then Filter Current Log:
Setup filter as shown below:
Then look for SQL-related events:
Usually event text provides information why MSSQLSERVER service fails to start. If the text is unclear please google it for more details.
If your problem was the same as mine (or to anyone else whose attempting to connect to their MS SQL Server w/ a similar connection string), MSSQLSERVER is the default instance name when you set it up, if you don't provide an instance name. I omitted the MSSQLSERVER from the connection string and I was successfully able to connect.
With all respect to "Anton Kruglov" and "marc_s" , Unfortunately, my problem is not resolved . I had to change my windows and reinstall softwares . Now it works properly .
I have the following situation:
A sql server 2014 is installed
While the server was shutdown the hard drive the databases were on had troubles which resulted in the loss of these files
So now I have the situation that the server has databases configured to be existing where the files don't exist any longer.
When I now try to start the sql server via the configuration tools it does not start and in the log files I see that he throws an error that he doesn't find the database files. When I tried to copy the same files there from another server I still had the same problem but the error message was now "access denied" (as naturally they had different users).
So my question is: What (aside from a reinstall) can I do to get the sql server up and running again?
Change the database file permissions to allow access for SQL Server. Look at an existing file to see what permissions must be configured.
For some reasons I moved this folder : (Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL) to another drive, then returned it to the same location, but sql server has stopped working, showing this error when trying to start it again:
Windows could not start the SQL Server (MSSQLSERVER) on Local
Computer. For more information, review the System Event Log. If this
is a non-Microsoft service, contact the service vendor, and refer to
service-specific error code 3417.
I tried many solutions discussed in different forums, but none of them work for me.
The folder is not compressed or encrypted.
My sql server version is 2012:
Microsoft SQL Server Management Studio 11.0.3128.0
Microsoft Analysis Services Client Tools 11.0.3128.0
Microsoft Data Access Components (MDAC) 6.1.7601.17514
Microsoft MSXML 3.0 4.0 6.0
Microsoft Internet Explorer 9.0.8112.16421
Microsoft .NET Framework 4.0.30319.18047
Operating System 6.1.7601
Thanks for your kind help in advance.
Very simple to solve this problem.
Just open RUN window(Window+R) and type services.msc:
Services.msc window
Find the SQL within name column and right click on that.
right click on SQL as in screenshot
You will get properties option, click on properties.
One new window will be open and there you have to click on Log On tab. And select the Local System Account. then apply and okay.
Select Local system Account
After that come again in services.msc window. and right click on sql and click start.
And finally, SQL Server services started successfully. enjoy and keep learning.
Check if you did compress the driver or folder in where you put the .mdf file.
If so, plesae goto the driver or folder, change the compress option by
Properties -> Advanced and unticked the “Compress contents to save disk space” checkbox.
After above things, you should be able to start the service again.
Run this command after opening cmd as administrator
net start mssqlserver /T902
This command is called trace flag 902. It is used to bypass script upgrade mode. Every time when you try to start your sql service it also looks for script upgrades. and when the script upgrade fail your service unable to start. So, Whenever we have such upgrade script failure issue and SQL is not getting started, we need to use trace flag 902 to start SQL.
I hope this will help you..
In my particular case, I fixed this error by looking in the Event Viewer to get a clue as to the source of the issue:
I then followed the steps outlined at Rebuilding Master Database in SQL Server.
Note: Take some good backups first. After erasing the master database, you will have to attach to all of your existing databases again by browsing to the .mdf files.
In my particular case, the command to rebuild the master database was:
C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\SQLServer2012>setup /ACTION=rebuilddatabase /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=mike /sapwd=[insert password]
Note that this will reset SQL server to its defaults, so you will have to hope that you can restore the master database from E:\backup\master.bak. I couldn't find this file, so attached the existing databases (by browsing to the existing .mdf files), and everything was back to normal.
After fixing everything, I created a maintenance plan to back up everything, including the master database, on a weekly basis.
In my particular case, this whole issue was caused by a Seagate hard drive getting bad sectors a couple of months after its 2-year warranty period expired. Most of the Seagate drives I have ever owned have ended up expiring either before or shortly after warranty - so I'm avoiding Seagate like the plague now!!
This usually occurs when the master.mdf or the mastlog.ldf gets corrupt . In order to solve the issue goto the following path C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL , there you will find a folder ” Template Data ” , copy the master.mdf and mastlog.ldf and replace it in C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Data folder . Thats it . Now start the MS SQL service and you are done
I have had the same error recently. I have checked the folder Log of my Server instance.
x:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log\
and I have found this errors in logs
Starting up database 'master'.
Error: 17204, Severity: 16, State: 1.
FCB::Open failed: Could not open file
x:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\master.mdf for file number 1. OS error: 5(Access is denied.).
Error: 5120, Severity: 16, State: 101.
Unable to open the physical file "E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\master.mdf". Operating system error 5: "5(Access is denied.)".
Error: 17204, Severity: 16, State: 1. FCB::Open failed: Could not open file E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\mastlog.ldf for file number 2. OS error: 5(Access is denied.).
Error: 5120, Severity: 16, State: 101. Unable to open the physical file "E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\mastlog.ldf". Operating system error 5: "5(Access is denied.)".
SQL Server shutdown has been initiated
So for me it was an easy fix. I just added proper access rights to this files to the sql server service account.
I hope it will help
In My case I had to Upgrade the SQL Server since evaluation licence had been expired.
What is System Event Log saying?
Have you tried to repair:
Sql Server Installation Center -> Maintenance -> Repair
I was getting this error today. And above answers didn't help me. I was getting this error when I try to start the SQL Server(SQLEXPRESS) service in Services(services.msc).
When I checked the error log at the location C:\Program Files\Microsoft SQL Server\MSSQL13.SQLEXPRESS\MSSQL\Log, there was an entry related TCP/IP port.
2018-06-19 20:41:52.20 spid12s TDSSNIClient initialization failed
with error 0x271d, status code 0xa. Reason: Unable to initialize the
TCP/IP listener. An attempt was made to access a socket in a way
forbidden by its access permissions.
Recently I was running a MSSQLEXPRESS image in my docker container, which was using the same TCP/IP port, that caused this issue.
So, what I did is, I just reset my TCP/IP by doing the below command.
netsh int ip reset resetlog.txt
Once the resetting is done, I had to restart the machine and when I try to start the SQLEXPRESS service again, it started successfully. Hope it helps.
Go to the services and check if the SQL Server (MSSQLSERVER) service is running stop it and start your SQL Server (SQLEXPRESS) service it should work.
see the image:
Make sure both drive have the same partition - ( like FAT or NTFS, preferably NTFS ) also make sure he NETWORK SERVICE account, has the access.
Database rebuild fixed it for me as well. Also had to restore the old database from backup as it got corrupted during power outage...
The copy master.mdf procedure did not work for me.
i had the same problem before
the error code 3417 : the SQL SERVER cannot start the master database,
without master db SQL SERVER can't start
MSSQLSERVER_3417
The master database records all the system-level information for a SQL Server system. This includes instance-wide metadata such as logon accounts, endpoints, linked servers, and system configuration settings. In SQL Server, system objects are no longer stored in the master database; instead, they are stored in the Resource database. Also, master is the database that records the existence of all other databases and the location of those database files and records the initialization information for SQL Server. Therefore, SQL Server cannot start if the master database is unavailable
MSDN Master DB
so you need to reconfigure all settings after restoring master db
solutions
replace master mdf and ldf files with the same files from another instance of sql Server as long as its the same version reference
Rebuild System Databases refrence
reinstall sql server
I copied a master.mdf und mastlog.ldf from another Computer (luckily, we have a lot of Clients with the same configuration, otherwise template data would be perhaps necessary). I backed up the damaged master.mdf and mastlog.mdf. After that I replaced the bad ones with the ones from another Computer. And it worked. I needed to start the MSSQLSERVER Service of course. But, after that I had Problem that the user was already existing but orphaned (error code 15023), I executed the query
USE Database_name
EXEC sp_change_users_login 'Auto_Fix', 'username'
after that, everything was working smoothly. Hope this helps you and many thanks for this thread, saved me :)
Just rename the current ErrorLog to any other name like Errorlog _Old and change any old Log file to Error log file
try to start the SQL server services.. That's it. it will work..
Sql server error log file got corrupted. that is why it gives the problem even when you have all permissions.. when you delete it. new file will be generated.
I encountered this issue after changing database location. And I solved it by moving system databases back to their default locations. Although I will recommend not to move system databases like master and model to some other location. But if you want then you can refer to this article: https://learn.microsoft.com/en-us/sql/relational-databases/databases/move-system-databases?view=sql-server-2017
Re-entering credentials will help to start the services:
Start > Services
Right click on SQL Sever > Properties
Log On
Re-enter credentials and apply
Start the services now
The reason behind getting this Error Code : 3417 may be as follows:
One cause may be due to the Network account for the Data folder in
Program files.
The other reason may be because of some Windows
settings changed somehow.
Example: If for some reasons you have moved this folder (Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL) to another location then returned it to the same location. So, though it was returned to the same location the server may stop working and show error code 3417 when trying to start it again.
How To Fix SQL Error 3417
Go to "C:Program Files Microsoft SQLServerMSSQL.1MSSqLData"
Security/Permission settings
Network Service Account
Add a Network Service account
Then again check all
As stated here, you can try this third party tool as well.
A few times now, I've experienced various instances MS SQL Server to fail with this error after a Windows update. Most of the quick fixes above did not work for me.
What did:
copy all production databases over to some safe place
remove everything SQL Server via add/remove programs
get the latest SQL Server Express or Dev & install it
move the databases over to their home and reattach them.
For me, this was the fastest solution. Trying to find the cause of the error and fixing it is an afternoon of googling misty error messages. But YMMV.
In my case problem was about evaluation period expiration. I also went through this thread of StackOverFlow.You can investigate your problem by going to Event Viewer --> Windows Log (Application) and then search for your error id. For Step by Step guide to view error id in event viewer visit this...
I have a SQL Server 2012 database with filestream enabled. However, when I backup it and try to restore it on another SQL Server 2012 instance (on another machine), I simply get this message that:
No backupset selected to be restored.
Not even a single line of more explanation. What's wrong here?
Every other database without filestream is OK and can be restored successfully. Is it something related to filestream? Should I install a hotfix or something like that.
I had this problem and it turned out I was trying to restore to the wrong version of SQL. If you want more information on what's going on, try restoring the database using the following SQL:
RESTORE DATABASE <YourDatabase>
FROM DISK='<the path to your backup file>\<YourDatabase>.bak'
That should give you the error message that you need to debug this.
My problem ended up being permissions. I'm on a dev machine and copied via Homegroup. Somehow, probably based on where I copied the file to, the permissions got messed up and Management Studio couldn't read the file. Since this is dev I just gave Everyone permissions to the bak file and could then successfully restore via the GUI.
When running:
RESTORE DATABASE <YourDatabase>
FROM DISK='<the path to your backup file>\<YourDatabase>.bak'
It gave me the following error:
The media family on device 'C:\NorthwindDB.bak' is incorrectly formed. SQL Server cannot process this media family. RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)
Blockquote
Turns out You cannot take a DB from a Higher SQL version to a lower one, even if the compatibility level is the same on both source and destination DB.
To check the SQL version run:
Select ##Version
To see the difference, just create a DB on your source SQL server and try to do a restore from your backup file, when you do this whit SSMS, once you pick the backup file it will show some info about it as opossed to when you open it from a lower version server that will just say "no backupset selected to be restored"
So if You still need to move your data to a lower version SQL then check This.
Run SQL Server Management Studio as an administrator (right-click the shortcut/exe, then select "Run as Administrator"), then try to restore.
I thought I was not stupid enough to mix up the versions - however, I didn't realize that on my new server, a SQL Server 2005 instance was already installed from birth named SQLEXPRESS. When trying to restore my SQL Server 2008 R2 backed up database in SSMS 2012 to the SQLEXPRESS instance, the list of backup sets was empty.
Eventually I realized that the SQLEXPRESS instance on the server was not a 2012 instance, but a 2005. I disconnected and connected to the actual 2012 instance (in my case named SQLEXPRESS2012), and it (obviously) worked.
My problem was that my user was in the Builtin-Administrators group and no user with Sysadmin-role on SQL Server.
I just started the Management Studio as Administrator. This way it was possible to restore the database.
FYI: I found that when restoring, I needed to use the same (SQL User) credentials to login to SSMS. I had first tried the restore using a Windows Authentication account.
In my case, it was permissions and the fact that I used "Restore Files and Filegroups..." rather than simply "Restore Database ...".
That made the difference.
For me it's a user privilege issue.
I logged-in with sa user and its working fine.
For me the problem was having the .BAK file located in an encrypted folder on the server. Even with full Admin rights, I could never get SSMS to read the file. Moving the .BAK to an unencrypted folder solved my problem. Note that after moving the file you may have to also change the properties on the actual file to remove encryption (right click, properties, advanced, uncheck "encrypt contents to secure data".
In my case (new sql server install, newly created user) my user simply didn't have the necessary permission. I logged to the Management Studio as sa, then went to Security/Logins, right-click my username, Properties, then in the Server Roles section I checked sysadmin.
I had the same issue with SQL Server 2014 (Management Studio could not see the folder in which the backup file resided, when attempting to locate it for a Restore operation). This thread held the answer that solved my problem. Quote:
The SQL Server service account can be found by Start->Control
Panel->Administrative Tools->Services. Double-click on the SQL Server
service->Log On tab. You'll either be using the "Local System account"
or "This account" to define a specific account. If you are using the
Local System account, you won't be able to reference backups that are
not local to the server. If, instead, you have defined the account to
use, this is the account that needs to have access to the backup file
location. Your ability to access the backups using your personal logon
is irrelevant; it is the SQL Server account that is used, even though
you are initiating the backup. Your IT people should be able to
determine what rights are granted to each account.
Hope that helps someone.
For me, it was because the backup file was still open by another process. Here's the event log:
BackupDiskFile::OpenMedia: Backup device 'X:\Backups\MyDatabase\MyDatabase_backup_2014_08_22_132234_8270986.bak' failed to open. Operating system error 32(The process cannot access the file because it is being used by another process.).
Simply closing and reopening Sql Server Management Studio resolved it (so obviously it was ssms.exe that had the handle..)
In my case, it was a permissions issue.
For the Windows user, I was using did not have dbcreator role.
So I followed the below steps
Connect as sa to the SQL server
Expand Security in Object Explorer
Expand Logins
Right click on the Windows user in question
Click on Properties
Select Server Roles from Select a page options
Check dbcreator role for the user
Click OK
Another potential reason for this glitch appears to be Google Drive. Google Drive is compressing bak files or something, so if you want to transfer a database backup via Google Drive, it appears you must zip it first.
If you want to replace the existing database completely use the WITH REPLACE option:
RESTORE DATABASE <YourDatabase>
FROM DISK='<the path to your backup file>\<YourDatabase>.bak'
WITH REPLACE
Using SQL Server 2012 Express.
My error (from the SQL Manager - Restore Database Dialog):
No backupset selected to be restored
Further, there were no backupsets shown in the list to select.
The issue was that I had moved 1 of the 5 backup files to a folder where the SQL Server service logon user did not have permissions - I tried to add that user, but could not get the NT Service\MSSQL$SQLEXPRESS user into the security list.
I moved the file under the Documents folder for the service user, and that enabled it to read all the files I had selected - 4 at that point - and the error changed to "media set missing" - then I looked around for another backup file, and when I added that I was able to restore.
The answers in this question helped me look in the right places and work my way to a solution.
For me, It was a permission issue. I installed SQL server using a local user account and before joining my companies domain. Later on , I tried to restore a database using my domain account which doesn't have the permissions needed to restore SQL server databases. You need to fix the permission for your domain account and give it system admin permission on the SQL server instance you have.
I got the same error message even though I backup and restore on the same single machine.
The issue was from here: when backup, i had 2 item in the destination box.
So the fix would be: make sure only 1 item in the 'destination' box. Remove all the others if there are.
I have run into the same issue. Run SSMS as administrator then right click and do database restore. Should work.
I think I get the award for the most bone headed reason to get this error. In the Restore Database dialog, the database dropdown under Source is gray and I thought it was disabled. I skipped down to the database dropdown under Destination thinking it was the source and made a selection. Doing this will cause this error message to be displayed.
Greetings – To automate testing of our database SPROCs, we’ve been using dynamically created databases inside of a User Instance. This has been working very well – the build server and, until very recently, all the developers could all run the tests. However, one of our developer machines is now returning the following error when we try to connect to the user instance:
Failed to generate a user instance of
SQL Server due to a failure in
starting the process for the user
instance. The connection will be
closed.
Here is what the log file says:
2008-12-04 10:46:29.77 Logon
Error: 15372, Severity: 16, State: 1.
2008-12-04 10:46:29.77 Logon
Failed to generate a user instance of
SQL Server due to a failure in
starting the process for the user
instance. The connection will be
closed. [CLIENT: ]
What I’ve done to fix it so far
Deleted C:\Documents and Settings[username]\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data
Changed SQL Service to run as “Local System” instead of “Network Service”
Uninstalled SQL Express, deleted ALL data directories (e.g. “MSSQL.1”), and reinstalled SQL Express
None of these “fixes” have fixed the problem. It used to work on the machine in question, and we would like not to have to repave it.
Please help!!!
Thanks - Jordan
Okay, I tried all of the above fixes again, and then I restarted the entire system and it appears to work. Strange! I had restarted my system in the past, but it looks like you have to apply these fixes first and then restart. I think I'll try switching the service back to logging in as Network Service.
Thanks - Jordan
I found the same issue on my azure VM. Then I opened the SQL Server Configuration Manager, opened SQL Server Network Configuration, -Protocols for and found that "Named Pipes" and "TCP/IP" were disabled. I enabled them, and the error went away.