Sql User recovery - database

i have an problem with sql Oracle, basically I restored my pc and all the files had to be uninstalled, I recovered the oracle folder with the database saves, however now I can't log in on the user I was using before I restored my pc, how could I do to fix it?

Related

Restoring a running database in a different name in same server in SQL Server 2012 using Management Studio

I have SQL Server 2012 (64-bit) (MSSQL11)
running on Windows 2012 R2 (64-bit) (NT 6.3)
with .NET framework 4.0.
It has a database called db_X and since this is a live production database it is always running and stopping it is not an option.
This is the only SQL Server database server that I practically have.
I want to take a backup (i.e. a full backup) of db_X (which I know how to do) and restore that backup (that .bak file) under a different name (say db_Y) in the same SQL Server database server.
I created a new database called db_Y, then right clicked db_Y then went to Tasks --> Restore --> Database...
Then I gave the path to that .bak file (as source) and tried to restore it by giving db_Y as destination (with the option - overwrite the existing database i.e. WITH REPLACE)
But this is not working. It is giving an error.
It says restore of database db_Y failed. System.Data.SqlClient.SqlError: The file C:...\db_X1.mdf cannot be overwritten. It is being used by database db_X. Microsoft.SqlServer.SmoExtended.
But I still believe that this can be done using the Management Studio. Or at least using a script. (as this is a common requirement.)
Why is it trying to restore on db_X, when I have clearly given db_Y as my destination? Isn't this a bit scary as db_X is my live database (because I might lose some data)?
How is it possible to (have a copy of an existing and running database under a different name in SQL Server or in other words) restore a backup of an existing and running database with a different name in SQL Server 2012?
I am grateful if someone could kindly explain how this can be done using the Management Studio or at least using a script.
When you are restoring the database, you need to rename the database to something other than the name of the original:
And then click the Files section and makes sure the file names are different than the original database:

DBeaver restore SQL Server .bak file

I am just trying to restore a SQL Server .bak file in my DBeaver UI. But I have no idea how to do this - can someone help please?
I created a database, but when I right click on it, there are no restore options.
I do not see that option either in my version of DBeaver (6.1.3 - community). What you could do is initiate a restore with TSQL (by clicking on SQL Editor while you are connected to your database). Then in the Script area, use the below, modified for your own environment/database name.
USE [master] RESTORE DATABASE [DatabaseName] FROM
DISK = N'C:\FolderName\BackupName.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
For full Tsql options to restore a database, see this: RESTORE Statements (Transact-SQL)
In my case the database migration was done on windows environment so there was some issue restoring backup in Ubuntu 18.04 which was fixed from below command.
backup file path: /var/opt/mssql/data/
move file path: /var/opt/mssql/data/
Restoring database backup in Ubuntu using DBeaver
RESTORE DATABASE MYDB_API FROM DISK = N'/var/opt/mssql/data/mydb.bak'
WITH MOVE 'MYDB_API' TO '/var/opt/mssql/data/mydb.mdf'
, MOVE 'MYDB_API_log' TO '/var/opt/mssql/data/mydb_log.ldf'
REPLACE
Note: if above does not work for you then remove REPLACE from above and make sure MYDB_API does not exist on SQL Server.
It looks like you are using a macOS which is a system not supported by SQL Server Management Studio (SSMS).
So I assume you need to restore SQL Server database with .bak file under macOS GUI.
There is no GUI option to retore .bak file with DBeaver.
If you want absolutely a restoration with GUI and not TSQL, an alternative on macOS is Azure Data Studio (from Microsoft) which is an open source data management tool that runs on Windows, macOS, and Linux.
You can easily restore a bak file in GUI with Azure Data Studio.
Here is the tutorial:
https://learn.microsoft.com/en-us/sql/azure-data-studio/tutorial-backup-restore-sql-server
Restore a database from a backup file (With Azure Data Studio)
Open the SERVERS sidebar (CTRL+G), right-click your server, and select Manage.
Open the Restore database dialog (click Restore on the Tasks widget).
Select Backup file in the Restore from field.
Click the ellipses (...) in the Backup file path field, and select the latest backup file for TutorialDB.
Type TutorialDB_Restored in the Target database field in the Destination section to restore the backup file to a new database.
Click Restore
To view the status of the restore operation, press CTRL+T to open
the Task History sidebar.

SQL Server restoring to a different destination puts source DB into restoring state

I'm using a backup file to restore a database to a different database. The source database is the only one in the backup file and is selected as source.
A different database is the destination.
The restore option is overwrite the existing database (with replace). The restore as files are renamed to the destination database's files.
Other than the selected database's name in the file, the source is not involved at all in the restore.
After the restore the source database immediately goes into recovery and I have to restore it to get it out.
Even though it is not being touched.
Can anyone tell me how to stop this?
The server and studio versions are below.
Very much appreciated.
SQL Server 2008 (Version 10.0.2757.0)
SQL Server Management Studio 2012 (Version 11.0.6020.0)
(I have searched for this issue but found nothing fitting this description.)

I am not able to restore backup file in mssql

I have a .sql database which is from a different computer to ms-sql 2012 version.
When I try restoring it, it says: "no backup selected to be restored". I tried setting the permissions, tried restoring using restore tsql statement, but nothing seems to be working. Both are the same version, 2012.
restore database tables from disk='E:\tables\Tables.bak'

My database has been deleted suddenly on the server how to recover it?

I'm running an application on windows server that connect to a SQL Server database.
Today, when I opened SQL Server Management Studio, I was surprised the database is not in the list of the databases!
I don't know what's the reason. I searched in the server files but I can't find the database and also in the recycle bin.
I put my database in C:\db\myWeb.mdf and suddenly it's been removed!
Can anyone tell me how to recover the database?
UPDATE:
I used stealer phoenix to find the database files deleted on disk but unfortunately i didn't find the db then i tried to add new database with the same name of the deleted db but SQL management studio said that the database "MyWeb" already exist! that's mean it's some where in the server but i couldn't find it ?! .
The only thing you can do when the actual database files are missing is restore a backup of your server.
Optionally, when you have no backup, you could use a hard disk recovery tool (like Runtime GetDataBack to find the database files deleted on disk).

Resources