Home Database Mysql Tutorial MS SQL 迁移数据库文件

MS SQL 迁移数据库文件

Jun 07, 2016 pm 05:44 PM
database document migrate

MS SQL 数据库迁移文件, 这里说的不是将数据库迁移到另外一台服务器,只是在服务器不同磁盘目录内做迁移。 移动数据库文件的情况大致有下面一些: 1: 事先没有规划好,数据库文件或日志文件增长过快,导致某个盘或整个磁盘空间不足,需要移动数据文件或日志

MS SQL 数据库迁移文件,这里说的不是将数据库迁移到另外一台服务器,只是在服务器不同磁盘目录内做迁移。移动数据库文件的情况大致有下面一些:

  1: 事先没有规划好,数据库文件或日志文件增长过快,导致某个盘或整个磁盘空间不足,香港服务器,需要移动数据文件或日志文件

  2: 纯粹由于业务需求,数据增长过快。

  3: 为了更好的IO的性能,需要将数据文件、日志文件分布到不同磁盘,香港服务器,减轻IO压力,提供IO性能。

  4:故障恢复。例如,数据库处于可疑模式或因硬件故障而关闭。

案例:现在我在数据库实例中有数据库MyAssistant,(假设)由于事先没有规划好,导致数据文件位于E:\DataBase目录下, 我们需要将数据文件移动到D:\DataBase_Data目录下,

将日志文件移动到F:\DataBase_Log目录下。

clip_image002

步骤1:对数据库中每个要移动的文件(数据文件/日志文件),通过下面命令指定到新的目录

 

USE master MyAssistant MODIFY , FILENAME); MyAssistant MODIFY , FILENAME); GO

 

如果有多个数据库的数据文件/日志文件需要移动,可以通过一系列上述命令执行

ALTER DATABASE DATABASE_ID1 MODIFY , FILENAME); ALTER DATABASE DATABASE_ID2 MODIFY , FILENAME=.....mdf'); .......

 

 

步骤2:停止SQL Server实例,你可以在SQL Server Management Studio的配置工具Sql Server Configuration Manager下停止。也可用NET STOP MSSQLSERVER命令实现。

 

步骤3:将那些数据文件或日志文件手工移动到对应的目录(也就是上面命令中FILENAME对应的目录)

 

步骤4:重启SQL Server实例,验证数据文件迁移是否成功。

 

SELECT name, physical_name FROM sys.master_files WHERE database_id = DB_ID('MyAssistant');

 

二:迁移系统数据库文件

 

 迁移系统数据库文件与迁移用户数据库文件稍微有些不同

 

步骤1:如果SQL Server实例已经启动,那么停止该实例;这一步也完全可以忽略不做。

 

步骤2:修改启动参数(配置管理器-高级标签-启动参数)

 

 

-dD:\sqldata\master.mdf;

-eC:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\ERRORLOG;

-lE:\sqllog\mastlog.ldf

步骤3:关闭实例服务,拷贝master数据库的相关文件到目标文件。如上所示,把master数据的数据文件和日志文件分别从C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA下拷贝到D:\sqldata 和E:\sqllog\目录下。

 

步骤4:启动服务。检查OK没有问题后,香港服务器,删除master数据库在原C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA下的文件。

 

迁移model、msdb、tempdb数据库的步骤如下:

 

步骤1: 执行下面脚步

 

USE master GO MODIFY , FILENAME) ; msdb MODIFY , FILENAME) ; model MODIFY , FILENAME) ; model MODIFY , filename) ; tempdb MODIFY , filename) ; tempdb MODIFY , filename) ; GO

 

 

步骤2:停止SQL SERVER服务,移动数据文件到制定路径,需要注意的是:对于临时数据库,由于每次启动 MSSQLSERVER 服务时都会重新创建 tempdb,因此不需要从物理意义上移动数据和日志文件。

 

步骤3: 启动SQL SERVER服务,验证修改是否生效。

 

步骤4: 删除原来的数据文件。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to migrate WeChat chat history to a new phone How to migrate WeChat chat history to a new phone Mar 26, 2024 pm 04:48 PM

1. Open the WeChat app on the old device, click [Me] in the lower right corner, select the [Settings] function, and click [Chat]. 2. Select [Chat History Migration and Backup], click [Migrate], and select the platform to which you want to migrate the device. 3. Click [Select chats to be migrated], click [Select all] in the lower left corner, or select chat records yourself. 4. After selecting, click [Start] in the lower right corner to log in to this WeChat account using the new device. 5. Then scan the QR code to start migrating chat records. Users only need to wait for the migration to complete.

How does Go language implement the addition, deletion, modification and query operations of the database? How does Go language implement the addition, deletion, modification and query operations of the database? Mar 27, 2024 pm 09:39 PM

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

How to transfer WeChat chat history to another mobile phone How to transfer WeChat chat history to another mobile phone May 08, 2024 am 11:20 AM

1. On the old device, click "Me" → "Settings" → "Chat" → "Chat History Migration and Backup" → "Migrate". 2. Select the target platform device to be migrated, select the chat records to be migrated, and click "Start". 3. Log in with the same WeChat account on the new device and scan the QR code to start chat record migration.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

An in-depth analysis of how HTML reads the database An in-depth analysis of how HTML reads the database Apr 09, 2024 pm 12:36 PM

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

Cloud Modernization with C++: Migrating Legacy Applications to the Cloud Cloud Modernization with C++: Migrating Legacy Applications to the Cloud Jun 01, 2024 am 09:21 AM

The best way to move legacy C++ applications to the cloud: Re-platform: Move the application code to a cloud-native platform (such as Kubernetes) and leverage cloud services. Cloudization: Deploy applications on cloud platforms and utilize cloud services without code refactoring.

How to transfer WeChat chat history to another phone How to transfer WeChat chat history to another phone Mar 26, 2024 pm 04:50 PM

By opening WeChat on the old device, selecting "Chat History Migration and Backup" and following the prompts, users can migrate their chat history to the new device. The migration process involves selecting the chats that need to be migrated, scanning the QR code and waiting for the migration to complete.

See all articles