First, backup database
1. Open the SQL Enterprise Manager, click on Microsoft SQL Server2, SQL Server Group in the Contents of the Control Bengen -> Double click to open your server -> Double click to open the database directory 3, select your database name (such as forum database) Forum) -> Then click on the tool in the menu -> Select Backup Database 4, the Backup Options Select full backup, the backup in the destination is to select the name point to delete if the original path and name, then add, if it is not The path and name are directly selected, then specify the path and file name, specify the post point to determine if the backup window is returned, then the point is determined to make a backup
Second, restore the database
1. Open SQL Enterprise Manager, click on the Microsoft SQL Server2, SQL Server Group in the Contents of the Console, SQL Server Group -> Double click to open your server -> Click the new database icon, the name of the new database is 3 Click on the newly entered database name (such as the forum database forum) -> then click Tools in the Menu -> Select Restore Database 4. Select from Devices in the restore option in the pop-up window -> Point selection device -> Click Add -> and select your backup file name -> Add the point OK to return, then the device bar should appear the name of the database backup file you just selected, the backup number is 1 (if you are the same The file has been made multiple backups. You can click on the view next to the backup number. Select the latest backup after the check box) -> then click the option button next to the normal side 5, select in the window appearing Forced restore on existing databases, as well as options that make the database can continue to run but cannot restore other transaction logs in the recovery completion state. Restoring the database file for the intermediate part of the window To set up the installation of your SQL installation (you can also specify your own directory), the logical file name does not need to be changed, move to the physical file name to do according to your recovery machine situation Change, such as your SQL database in D: / Program Files / Microsoft SQL Server / MSSQL / DATA, then follow the directory of your recovery machine to change, and the last file name is best to change your current database name (If it is bbs_data.mdf, now the database is forum, change to forum_data.mdf), log and data files must be related to the related changes in this way (the file name of the log is * _log.ldf), Here you can freely set, provided that this directory must exist (if you can specify D: /SQLDATA/BBS_DATA.MDF or D: /SQLDATA/BBS_LOG.LDF), otherwise recovery will report an error 6, after the modification is complete, click The following determination is restored, then a progress bar, prompting the progress of recovery, the system will automatically prompt after the recovery is completed, such as the intermediate prompt error, please record the relevant error content and ask the person familiar with SQL operation, General errors are nothing more than directory error or file name duplicate or file name error or space is not enough or the database is in use, and the database is using an error. You can try to close all the SQL windows and reopen the recovery operation, if you still prompt you Used error can stop the SQL service and then restarted, as for other errors, it can be restored after the error content is changed accordingly.
Third, shrink database
Under normal circumstances, the shrinkage of the SQL database does not greatly reduce the size of the database. The main role is to shrink the log size. This action should be performed regularly to prevent the database log excessively 1. Setting the database mode as simple mode: Open SQL Enterprise Management In the control station root directory, click Microsoft SQL Server -> SQL Server Group -> Double click to open your server -> Double click to open the database directory -> Select your database name (such as the forum database forum) -> Then click Right click Select Properties -> Select Options -> Select "Simple" in the fault restore mode, then press OK Save 2, right-click on the current database, see the contraction database in all tasks, generally The default setting is not adjusted, the direct point is determined 3, after the shrink database is completed, it is recommended to reset your database properties to standard mode, the operation method is the first point, because the log is often the important basis for the restoration of the database in some abnormalities. Set a daily automatic backup database
It is highly recommended that there is a conditional user! 1. Open Enterprise Manager, click on the Microsoft SQL Server -> SQL Server Group -> Double click on your server 2 in the root directory of the Control Station -> Select the Database Maintenance Planner above the menu 3, Next Select data to be automatically backed up -> Next update data optimization information, here usually do not do the choice -> Next check data integrity, it is generally not selected 4, the next specified database maintenance plan, default One week backup once, click Change Select Once After you back up, you can determine 5. Next Specify the backup disk directory, select the specified directory, such as you can create a directory in D: DATABAK, then choose to use here This directory, if your database is better to choose to create a subdirectory for each database, then select Remove how many days ago, you will set 4-7 days, see your specific backup requirements, backup file extensions Names are generally BAK to use the default 6, the next step specify the transaction log backup plan, see your needs to do the choice -> The report to generate, generally do not choose -> Next Maintenance plan history, most It is easy to use the default option -> Next step 7, the system is probably prompting the SQL Server Agent service not started, first determine the completion plan setting, then find the SQL green icon in the rightmost status bar in the desktop, double click Open, select the SQL Server Agent in the service, then click the run arrow, select the automatic start service 8 when the OS is started, this time the database plan has been successful, and he will automatically back up the above settings.
Modifying plan: 1. Open Enterprise Manager, click on Microsoft SQL Server in the Contents Grant Catalog -> SQL Server Group -> Double click to open your server -> Management -> Database Maintenance Plan -> Open After you can see your settings, you can modify or delete the operation.
V. Data transfer (new database or transfer server)