search
HomeDatabaseMysql TutorialMS SQL 迁移数据库文件

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
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
What are some tools you can use to monitor MySQL performance?What are some tools you can use to monitor MySQL performance?Apr 23, 2025 am 12:21 AM

How to effectively monitor MySQL performance? Use tools such as mysqladmin, SHOWGLOBALSTATUS, PerconaMonitoring and Management (PMM), and MySQL EnterpriseMonitor. 1. Use mysqladmin to view the number of connections. 2. Use SHOWGLOBALSTATUS to view the query number. 3.PMM provides detailed performance data and graphical interface. 4.MySQLEnterpriseMonitor provides rich monitoring functions and alarm mechanisms.

How does MySQL differ from SQL Server?How does MySQL differ from SQL Server?Apr 23, 2025 am 12:20 AM

The difference between MySQL and SQLServer is: 1) MySQL is open source and suitable for web and embedded systems, 2) SQLServer is a commercial product of Microsoft and is suitable for enterprise-level applications. There are significant differences between the two in storage engine, performance optimization and application scenarios. When choosing, you need to consider project size and future scalability.

In what scenarios might you choose SQL Server over MySQL?In what scenarios might you choose SQL Server over MySQL?Apr 23, 2025 am 12:20 AM

In enterprise-level application scenarios that require high availability, advanced security and good integration, SQLServer should be chosen instead of MySQL. 1) SQLServer provides enterprise-level features such as high availability and advanced security. 2) It is closely integrated with Microsoft ecosystems such as VisualStudio and PowerBI. 3) SQLServer performs excellent in performance optimization and supports memory-optimized tables and column storage indexes.

How does MySQL handle character sets and collations?How does MySQL handle character sets and collations?Apr 23, 2025 am 12:19 AM

MySQLmanagescharactersetsandcollationsbyusingUTF-8asthedefault,allowingconfigurationatdatabase,table,andcolumnlevels,andrequiringcarefulalignmenttoavoidmismatches.1)Setdefaultcharactersetandcollationforadatabase.2)Configurecharactersetandcollationfor

What are triggers in MySQL?What are triggers in MySQL?Apr 23, 2025 am 12:11 AM

A MySQL trigger is an automatically executed stored procedure associated with a table that is used to perform a series of operations when a specific data operation is performed. 1) Trigger definition and function: used for data verification, logging, etc. 2) Working principle: It is divided into BEFORE and AFTER, and supports row-level triggering. 3) Example of use: Can be used to record salary changes or update inventory. 4) Debugging skills: Use SHOWTRIGGERS and SHOWCREATETRIGGER commands. 5) Performance optimization: Avoid complex operations, use indexes, and manage transactions.

How do you create and manage user accounts in MySQL?How do you create and manage user accounts in MySQL?Apr 22, 2025 pm 06:05 PM

The steps to create and manage user accounts in MySQL are as follows: 1. Create a user: Use CREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password'; 2. Assign permissions: Use GRANTSELECT, INSERT, UPDATEONmydatabase.TO'newuser'@'localhost'; 3. Fix permission error: Use REVOKEALLPRIVILEGESONmydatabase.FROM'newuser'@'localhost'; then reassign permissions; 4. Optimization permissions: Use SHOWGRA

How does MySQL differ from Oracle?How does MySQL differ from Oracle?Apr 22, 2025 pm 05:57 PM

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

What are the disadvantages of using MySQL compared to other relational databases?What are the disadvantages of using MySQL compared to other relational databases?Apr 22, 2025 pm 05:49 PM

The disadvantages of MySQL compared to other relational databases include: 1. Performance issues: You may encounter bottlenecks when processing large-scale data, and PostgreSQL performs better in complex queries and big data processing. 2. Scalability: The horizontal scaling ability is not as good as Google Spanner and Amazon Aurora. 3. Functional limitations: Not as good as PostgreSQL and Oracle in advanced functions, some functions require more custom code and maintenance.

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use