Database Credentials

  • Hello All

    A few months back I created a small database on SQl 2005 and copied the database files over to my backup drive. Now I need to restore that database to another machine. I have forgot the username and password for that database all I have are .ldf, .mdf, and .bak files. Would someone let me know how can I restore that database without username and password

    Any help would be appreciated.

    Thanks

    Freebyte

  • Are you able to login to the SQL Server on the other machine?

    Have you tried to restore the database from the backup? What error message did you get?

    Is the .BAK backup file passwork protected?

    There is no username and password at database level in SQL Server.

    Since you have .MDF and .LDF files, you can attach them.

  • I was hesitant to answer because this almost sounds like a hacking venture, but... You can do a restore without having the user name and password. Once the database is restored, it can be accessed by the administrative accounts on your server. This assumes that the db in question isn't encrypted. If it is, this sounds even more like a hacking venture.

    You can also attach a database as mentioned above, once again assuming it's not encrypted.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thanks for the reply.

    Yes you are right. It sounds like it is a hacking attempt but it is not. You do not have any compelling reaons to beleive me except taking my words on it. I have created this database during a training and at that time I did not know much about the SQL. In fact I do not know much about it right now as well. I just needed to know how can I resotore it from a .BAK or LDF and MDF file. I just do not seem to find a way to restore it to my new server. Keep in mid that it was created on a different server with a different username and password which I do not seem to remember.

    Thanks and Regards

    Freebyte

  • As long as it's not encrypted, you can restore the database using the RESTORE DATABASE syntax. From the BOL:

    RESTORE DATABASE { database_name | @database_name_var }

    [ FROM [ ,...n ] ]

    [ WITH

    {

    [ RECOVERY | NORECOVERY | STANDBY =

    {standby_file_name | @standby_file_name_var }

    ]

    | , [ ,...n ]

    | ,

    | ,

    | ,

    | ,

    } [ ,...n ]

    ]

    [;]

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • If you have the ldf/mdf, I'd try attaching first. If that doesn't work, then try the restore.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply