Stand-alone online game setup must learn: database backup and transfer

The basic operation of SQL2000 should be able to.
If you have a database and want to share it with your friends, how do you do it? Maybe you think it is very simple, just send the database file to your friends directly by QQ or email.
Actually not. Because the database file is occupied by the SQL2000 server, you cannot directly operate the database file. Do not believe? Let's take a look:

Right-click the database Test123, click Properties

 

Then select "data file", you can see the location of the database file

Enter this location, we pack these two files 

 

see it? Packing is not allowed because the two database files are occupied.
Similarly, copying these two files to other places will not work.
Therefore, it is not acceptable to directly send the database file to your friend.
Smart friends may have already thought of the answer: because these two files are occupied by the SQL2000 server, can the SQL2000 server be suspended or stopped, can these two files be copied or sent directly? Yes.
Then let's take a look at how to stop the server of SQL2000. 

1. Backup, compress, copy or send your SQL database files directly

Open the "Service Manager"

Then click "Stop", thus stopping the server of SQL2000.
After stopping the server of SQL2000, the database service will stop, so that the website, software and games of the database in this server will not be able to connect to the database.

Then compress and pack the two database files of Test123, and see, it succeeded. In this way, you can directly backup, compress, copy or send your SQL database files.
You send this compressed package to your friend, and after your friend receives it, decompress it on his computer, then attach it to his database, and it's done.

2. Attach the SQL database file
(in order to demonstrate how to attach the database, I deleted Test123, and there is no Test123 database in the database now)
and then I decompressed the compressed package of Test123.rar to the "D:\data\" folder ( Unzip it wherever you want, it doesn’t affect the attachment. Let’s assume that the database of Test123 is sent to you by your friend, or it can be downloaded from the Internet. Anyway, no matter where it comes from, you want this database to get into your SQL2000 server. Use)
to see how to attach (attach means to add the database file to the SQL2000 server):

 

Right click on the database, select all tasks --> attach database
 

Click the button to select the database

Select the MDF file you want to attach

Then click OK, it will prompt that the attachment is successful. (Note: SQL2000 cannot attach database files of SQL2005, SQL2008... etc. In theory, SQL2000SP3 cannot attach SQL2000SP4 files. ----SP4 and SP3 mean patches, SP=Service Pack, after SQL2000 is released, Many new problems will accumulate during continuous use, including security issues, so Microsoft officially released patches. SP3 refers to the third patch, and SP4 refers to the fourth patch. The higher the patch, the software version The higher the version, the lower version does not recognize the higher version, just like time travel, the ancients did not understand mobile phones and computers)

Lo and behold, the Test123 database appears.

3. Back up database files

After stopping the database, you can easily operate the database files. Is this the best operation plan (backup, copy, share, etc.) of the database?
Actually not. Think about it, if there is a professional database server with 100 databases on it, and you only purchased one of the databases (space) for use, do you think that the server provider will send you the account number and password of the server to let you go up and stop? database, copy your database away? It is obviously impossible. Furthermore, once you stop the server of SQL2000, all 99 other databases will be stopped by you, uh. . . If people use it for websites and software, wouldn't the service and business stop? If everyone can operate in this way, others will also stop the database, and your database will also be inaccessible... It can be seen that
this series of problems makes it impossible for you to operate the database file after stopping the database server.
Then it is necessary to back up and copy the database files without stopping the database. This requires a backup of the database.
Come on, let's see how to backup:

Right-click the database to be backed up, select all tasks --> backup database
 

Click the "Add" button to specify where to backup
 

Let's back up here. The extension of the general backup file is called bak.

Then click OK, after the backup is complete, it will prompt that the backup is successful. In this way, even if your database is in use, it can be backed up without shutting down the database server.

Look, this backup file appears, the backup was successful.

4. Restore the database file

If someone sends you a backed up database file, will you restore it to your database server?
(Here I deleted the database of Test123 again, let's restore it), see the picture:

 

 

 

 Right click on the database, all tasks - restore database

"Restore" select "From Device", and then click "Select Device"

Then click "Add" to add the database file to be restored

 

 Here we choose the tes123Bak.bak file, click OK

At this time, "restore to database", please fill in the name of the database you want to restore, we still restore to Test123. 

 

Click the "Options" tab, "Move to physical file name" here, the folder must exist, if it does not exist, the restoration is unsuccessful. For example, your "D:\Data\" folder does not exist, then the restore will fail as shown in the picture, either you create a new "D:\Data\" folder, or you change it to another existing one folder.
Click OK, and then it will prompt that the restoration is successful.


Look, the Test123 database appeared, and the restore was successful. 

 A. Add the account number and password of SQL2000
directly to the above picture:

Click Security, right-click Logins, and select New Login 

 

The name is the account number, select SQL Server authentication for authentication, and fill in the password you want to set for the password.
As for server roles and database access, they specify the permissions owned by this account and the databases that this account can access.
After setting, click OK to complete. 

 B. Change the password of SQL2000
directly above the picture:

Left-click to log in, right-click the account whose password needs to be changed in the main display area, and click Properties
 

Enter a new password in the password box, click OK

A password confirmation box will pop up, enter it again and it will be ok. If you don't understand anything, you can leave a message and private message me. 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/2301_78546196/article/details/132041742