how to restrict sql database to be opened in other servers? - sql-server

Currently i have a database that is attached to a named instance server with login credentials ,but at the same time if i attach the database to another server in other system ,the same gets opened.
How to deal with this?
Is there a way to restrict the database file to opened by others without valid credentials ?

You can do a BACKUP with MEDIAPASSWORD.
Here is the T-SQL command to backup your database:
BACKUP DATABASE Northwind TO DISK='C:\abc.BAK' WITH MEDIAPASSWORD='abc12345'
Reference Links:
Backup

Related

Restore .bak on Azure SQL database through SSMS: Failed to connect to Server ***. Login Failed for user ***

I am trying to restored a .bak file on an Azure SQL server through SSMS.
The reason why I am doing this is that my company unfortunately blocked any action on the Azure portal itself and therefore I have to find another way around.
I am able to connect successfully to the DB on Azure with my admin account through SSMS.
I first successfully restored the .bak on my local database. And then I am trying:
Again, I am able to connect through the same SSMS to the SQL db.
Moreover, when starting this procedure I get asked to connect first to the DB, which works successfully! What I mean is:
It doesn't give me any error, which is weird because if I try to connect with a wrong password it tells me right away that is wrong. So it kind of accepts it. It's only after when I really start the deployment that it gives me the problem:
Just for now, Azure SQL database doesn't support restore from .bak file.
You work flow should be right, restore the .bak file(database) into a local SQL Server firstly, then deploy the restored database to Azure with "Deploy database to Microsoft Azure SQL database".
Make sure you are using the server admin account of the Azure SQL database. Per my experience, the error is usually caused by the permission limits.
If all of these(SSMS) don't work, please thy other ways. Please try Data Migration Assistant(DMA) migrate the database. If DMA still give the same error, we can ensure that it's not caused by the tools, you need another higher Azure SQL database account permission.
HTH.
Working solution was to use the export data task:
For some reason this worked and the publish to ASQL task from SSMS didn't. I understand this is very based on the restrictions imposed by my company but at least this solution worked.
NOTE: as both Source and Destination use SQL Server Native Client .
Moreover when setting the Destination the refresh of the list of databases might not work (depending on your permissions on Server level) but if you type directly the name of the database it will work. Talking about this:

Uploading a database to server

How do I upload to my local host database to a server uses direct admin.
I tried to take a .gz file from my local host database and when uploading it to the server It said that it is not a backup database. So do I have to create the database tables and columns by my own self not by uploading it?
In Direct Admin Under MySQL management, Create a new MySQL database and user with sufficient privileges.
Go to PHPmyAdmin, Select the database you just created and choose the import tab. Upload the gz file and hit Go! The localhost database tables are now in your server.

How to restore DNN Backup

I have taken DNN 6 backup in the following ways
Copy the DNN folder from C:\inetpub\wwwroot
Take Sqlserver 2008 Enterprise edition database backup
When I try to restore it, I am getting error:
Connection Error(s): Index #: 0 Source: .Net SqlClient Data Provider
Class: 14 Number: 18456 Message: Sql login failed
I am using the following link for restoration:
.../Install/InstallWizard.aspx
Note !!! When i change the database and username, it will install the fresh installation but not restoring backup database.
How to solve this problem?
Some of the answer here will depend on where/how you are restoring the database.
If you take a database from one server to the other, the user account does NOT come with it from a server login perspective. So after restoring the database, you will need to create a new user account for managing the access to the database.
I'm not sure about needing to run the /InstallWizard.aspx to perform a restore. The first step is to get the files laid down in the Windows directory you want, and then get the IIS setup and pointed properly ensuring that you have the right security access (Depending on your version of IIS) to the files. If you get all that right you will be good to go from a file perspective.
As far as SQL Server you will need to do a manual database restore and as Mitch says create a new account that will have access to the database - You will need to change both database access statements the web.config to specify the new user. (standard and legacy if they both exist) Finally, make sure that SQL server is configured in Mixed Mode Authentication if you are specifying a SQL user.

Please explain SQL Azure "master" database

What's the "master" database in SQL Azure for? I just created a subscription and once I created a "new SQL Server" I immediately got "master" database with 1GB size. That database can't be deleted - "delete" button is not active in the management portal.
When I tried to deploy a .dbproj project there Visual Studio said it "couldn't deploy to a system database".
Can I use that database for storing my data? Do I create a new database instead?
Just a note: you will not be charged for the master DB.
master is a required system database that's responsible for holding info about all the the other database on the server instance, system metrics/config, managing logins & database creation etc, its read-only and can't be removed.
You will need to create a new database and deploy to that.
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

How to convert user instance database to normal sql server database

can anybody help me by providing a link on how to convert a user instance database to normal sql server database. Thanks in advance.
Copy the user instance MDF to a new directory. From SSMS, right click "Databases" and then Attach.

Resources