分类: SQLServer
2013-07-19 21:04:42
移动model,msdb,tempdb等数据库文件位置
USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\tempdb.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\templog.ldf');
GO
GO
ALTER DATABASE model
MODIFY FILE (NAME = modeldev, FILENAME = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\model.mdf');
GO
ALTER DATABASE model
MODIFY FILE (NAME = modellog, FILENAME = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\modellog.ldf');
GO
GO
ALTER DATABASE msdb
MODIFY FILE (NAME = MSDBData, FILENAME = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\msdbdata.mdf');
GO
ALTER DATABASE msdb
MODIFY FILE (NAME = MSDBLog, FILENAME = 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\msdblog.ldf');
GO
移动mssqlsystemresource数据库文件位置
需要先停止mssqlserver服务,进入修复模式,运行:d:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn>sqlservr.exe –f,执行以下SQL代码
ALTER DATABASE mssqlsystemresource
MODIFY FILE (NAME=data, FILENAME= 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mssqlsystemresource.mdf');
GO
ALTER DATABASE mssqlsystemresource
MODIFY FILE (NAME=log, FILENAME= 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mssqlsystemresource.ldf');
GO
这些都只是变更了master数据库中关于这些数据库的位置信息,执行成功之后,再把相应数据库文件拷贝到新的位置,启动MSSQLSERVER服务即可