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

    Postgresql issues with a cPanel server

    Recently with a cPanel server, we had this issue of not being able to create postgresql database even after the postgresql package is installed and database server is running. Fixing of one issue lead to another there by needing to fix all the errors.

    Cpanel::AdminBin::adminrun(postgres) set error in context postgres
    [2010-01-16 12:24:18 -0500] warn [postgres::listdbs] Encountered error in postgres::listdbs: Error from postgres wrapper: PostgreSQL has not been configured by the administrator. Unable to locate pgpass file.

    This was fixed by doing these,

    Login to WHM => SQL Services => Postgres Config => Click on “Install Config”.
    Login to WHM => SQL Services => Postgres Config => “Set a Postgresql password also”

    No error in cPanel after doing above. However that followed by an issue of created DBs not being appeared in the List DB page of Postgresql databases. Went to shell. Logged in as root . Switched to postgres. “su – postgres” . Ran the command “psql” and then

    -bash-3.2$ psql
    Welcome to psql 8.1.18, the PostgreSQL interactive terminal.

    Type: \copyright for distribution terms
    \h for help with SQL commands
    \? for help with psql commands
    \g or terminate with semicolon to execute query
    \q to quit

    postgres=# \l
    List of databases
    Name | Owner | Encoding
    -----------+----------+----------
    postgres | postgres | UTF8
    template0 | postgres | UTF8
    template1 | postgres | UTF8
    (3 rows)

    postgres=# \q

    No DB was created. Checked the logs /usr/local/cpanel/logs/error_log and it had entries like ERROR: role “username” does not exist which meant, no roles to create the database.

    cd /var/cpanel/users && for x in *; do su -c "createuser -S -D -R $x" postgres; done

    Continue Reading

    Enabling mod_rewrite in Apache 2.2

    By default CentOS or RHEL flavours of Linux has Apache 2.2 installed. It often becomes a requirement to enable mod_rewrite on these servers. Techs who have been working with cPanel and server with control panels often finds it difficult to troubleshoot issues with a bare server. There are a few things to check or commands to execute in such case where mod_rewrite is shown enabled in the httpd.conf, but not working.

    [root@cave html]# httpd -V
    Server version: Apache/2.2.3

    [root@cave html]# httpd -M
    Loaded Modules:
    core_module (static)
    mpm_prefork_module (static)
    http_module (static)
    so_module (static)
    auth_basic_module (shared)
    auth_digest_module (shared)
    ….
    …….
    ….
    rewrite_module (shared)
    proxy_module (shared)
    proxy_balancer_module (shared)
    proxy_ftp_module (shared)
    proxy_http_module (shared)
    proxy_connect_module (shared)

    [root@cave html]# a2enmod rewrite

    a2enmod is only to be used if the rewrite_module is not enabled in httpd.conf

    Check for the “AllowOverride” settings. It should be set to “All“. By default it will be “None

    Things should work fine after this. Also I found a small good script to check at this URL to see whether mod_rewrite is enabled or not http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

    Good Luck guys!

    Continue Reading

    Magento Suhosin Values

    Sometimes Magento admins face the issue of some values missing from the frontend even though the configuration would have shown to be saved from Backend. This could be due the limit in the number of values set by suhosin.

    The common override for this issue is to have the following values set in .htaccess

    php_value suhosin.mail.protect 0
    php_value suhosin.memory_limit 128M
    php_value suhosin.post.max_vars 5000
    php_value suhosin.post.max_value_length 500000
    php_value suhosin.request.max_vars 5000
    php_value suhosin.request.max_value_length 500000
    php_flag suhosin.session.cryptua off

    For php.ini use the variables without php_value or php_flag

    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