MSSQL – Two common issues while restoring a backup and it’s solutions

There are two most common issues while restoring the database (usually ending in .bak format).

First error
System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing ‘user_database‘ database. (Microsoft.SqlServer.Express.Smo)

Solution for First error

  • Connect to the database server
  • Logging in to the web server

  • Go to the restore option and select Restore Database

  • On the Restore page that loads up, make sure that the Destination for restore has the database you want to restore and in the Source for Restore, choose From device: And browse by clicking [..] and Add the file location there, the location where your database backup resides. You may need to browse the backup. If you get permission denied, copy the bak in the MSSQL folder.

    Attaching the database backup file

    Attaching the database backup file

  • Restore it. Make sure that the Restore Checkbox is selected. And Click OK. And get ready for the error :)

  • Here comes the first errorSystem.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing ‘user_database’ database. (Microsoft.SqlServer.Express.Smo)
    And the solution is to go to Options -> Overwrite Existing Database . But if you aren’t so lucky, you will be welcomed by another error as seen below. where it’s solution is to edit the path from D:\ to C:\ or whichever Drive, where your MSSQL is installed.

    System.Data.SqlClient.SqlError: Directory lookup for the file “D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\user_database.mdf” failed with the operating system error 3(The system cannot find the path specified.). (Microsoft.SqlServer.Express.Smo)

  • Both THE Solutions are in a single screen shot. The final screenshot :)

  • Just edit D:\ProgramFiles\Microsoft… to C:\ProgramFiles\Microsoft or whichever directory where you installed the MSSQL server. Don’t keep database server on your system drive C: though.
  • Continue Reading

    HTTP 405: The HTTP verb used to access this page is not allowed

    On an html page, one of our customers was getting this issue. Despite asking him to change the extension to .asp, he insisted to have html extension and still process the HTTP verbs, where it is POST method here.

    Situation becomes like this a static page wants to be read a dynamic page and process the values obtaining from POST method. Solution is to make the .html read as .asp with asp dll, just like we do html parse as php in Linux boxes Here are the steps to do it on a Windows 2003 machine

    1. Start –> Run –> inetmgr
    2. Websites –> website/domain name in question
    3. Right Click on the domain –> Properties –> Home Directory –> Configuration
    4. In the tab Mappings –> Add an extension for .html and .htm , if it is missing (most cases it will be missing) and edit to add all verbs (POST, GET, HEAD are needed)
    5. Fields to be added are as below,

    Executable : C:\WINDOWS\system32\inetsrv\asp.dll
    Extension : .html
    Limit to : GET,HEAD,POST,TRACE

    And Click Apply, OK :) All is well !!

    Continue Reading

    Bad Request (Invalid Hostname) when accessing via IP

    Customer wanted to have a dedicated IP, but once I change the IP from the plesk control panel, I couldn’t get the website when accessed using IP. Instead, it was giving me the plesk control panel’s default page. Reason ? Default Website was having the IP as “All Unassigned”. Set that to the main IP address. But after that I was getting a new error.

    What I could get was “Bad Request (Invalid Hostname)” in bold letters. Here is what I did to fix the same.

    Start -> Run -> inetmgr -> Expand the (+) -> Websites -> Right click on the domain name -> Take Properties -> Website -> IP Address (make sure that it has the dedicated IP assigned there) and then click “Advanced”

    Add/Edit Web Site Identification

    IP Address : Choose the dedicated IP from drop down list
    TCP/IP Port : 80
    Host Header Value : Leave it blank (Important)

    Leaving the Host Header Value should fix the issue and fetch the website when accessing it using the IP.

    Continue Reading

    Plesk account unsuspension – Table::select() failed: no such row in the table

    Account was suspended and now when trying to unsuspend it was causing errors like

    DNSZone::Table::select() failed: no such row in the table

    Environment : Plesk 9.2 and Windows 2003 OS.

    Solution

    Identify the database which plesk uses. Now a days plesk choose MSAccess as the Database. Earlier days the choice was MSSQL and MySQL. Better choices now. Details on how to edit the database is at this KB url : http://kb.parallels.com/en/3472

    Once you have it follow the next KB available at http://kb.parallels.com/en/1360 . This KB is meant for MySQL. But all other steps will work for MSAccess DB as well. Usually DB is at %plesk_bin%\admin\db\psa.mdb

    Basically a few commands

    find domains which have missed ID:

    mysql> SELECT d.name FROM domains d LEFT JOIN dns_zone z ON d.dns_zone_id=z.id WHERE z.id IS NULL;

    Then for each reported domain do the following:

    1. create appropriate id records with following commands, do not forget to replace DOMAN-NAME with a real domain name and ADMIN-EMAIL with a correct email:

    mysql> INSERT INTO dns_zone (name, displayName, email) VALUES ('DOMAIN-NAME', ‘DOMAIN-NAME', 'ADMIN-EMAIL');

    2. know new zone ID:
    mysql>  SELECT id, name FROM dns_zone where name='DOMAIN-NAME';

    3. substitute correct ID into psa.domains table, don’t forget to replace DOMAN-NAME and DNS-ZONE-ID with correct values:

    mysql> UPDATE domains SET dns_zone_id='DNS-ZONE-ID' WHERE name='DOMAIN-NAME';

    Once it is done, take DNS Settings and then under the domain in question, do Restore Defaults. After that do the needed modification along with unsuspension of the domain. It should work!! Or else make it work :)

    Continue Reading

    How to recover forgotten plesk password from a Linux or Windows Dedicated or VPS server

    To Recover your plesk password on a Linux Dedicated or VPS Server

    1. Login as root to the server using ssh
    2. Then issue the command below, to see your plesk password cat /etc/psa/.psa.shadow

    To Recover your plesk password on a windows dedicated or VPS server

    1. cd %plesk_bin%
    2. Make sure that you ended up in a folder which is a line similar to “C:\Program Files\SWsoft\Plesk\admin\bin\” If not, you will have to do a “D:\” or so depending on which drive or disk you installed Plesk on and then issue the below command
    3. plesksrvclient.exe -get
    Continue Reading

    About this blog

    This blog, acts as a knowledge repository for the world and is unofficial! Anything we find interesting in the cyber world will go here. Most cases, this blog will reflect the happiness of our staff in reaching successful solution to an issue (s)he worked on. A reference for other fellow SAGEs who come across similar issues later