Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the storage location of database physical files in SQL Server

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article shows you how to modify the storage location of database physical files in SQL Server. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The specific process is as follows:

1. Take the existing database offline

ALTER DATABASE DB1 SET OFFLINE WITH ROLLBACK IMMEDIATE

2. Move the database file to a new location

After the file is copied, you need to: right-click-attribute-Security-add Authenticated Users- to the group or user name to change the group permission to full permission, otherwise the next operation will report

Possible problems in the middle:

Message 5120, level 16, status 101.Line 17 cannot open the physical file "D:\ MSSQL\ DATA\ testdb.mdf". Operating system error 5: 5 (access denied.) " . Message 5120, level 16, status 101.Line 17 cannot open the physical file "D:\ MSSQL\ DATA\ testdb _ log.ldf". Operating system error 5: 5 (access denied.) " . Message 5181, level 16, status 5, line 17 cannot restart the database "ctrip". Will return to the previous state. Message 5069, level 16, status 1, line 17 ALTER DATABASE statement failed.

3. Modify the direction of the database associated file

ALTER DATABASE DB1 MODIFY FILE (NAME = DB1, FILENAME = X:\ SQLServer\ DB1.mdf); ALTER DATABASE DB1 MODIFY FILE (NAME = DB1_Log, FILENAME = X:\ SQLServer\ DB1_Log.ldf)

4. Bring the database online

ALTER DATABASE DB1 SET ONLINE; the above is how to modify the storage location of database physical files in SQL Server. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report