強制關閉指定資料庫連線
還原資料庫的時候是不是經常出現資料庫正在使用無法還原?
雖然關掉所有程式,可是還是還原不了資料庫?
執行以下**吧!
/*
斷開所有使用者開啟的連線
*/
use master
go
if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[p_killspid]') and objectproperty(id, n'isprocedure') = 1)
drop procedure [dbo].[p_killspid]
go
create proc p_killspid
@dbname varchar(200) --要關閉程序的資料庫名
as
declare @sql
nvarchar(500)
declare @spid nvarchar(20)
declare #tb cursor for
select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname)
open #tb
fetch next from #tb into @spid
while @@fetch_status=0
begin
exec('kill '+@spid)
fetch next from #tb into @spid
end
close #tb
deallocate #tb
go
--用法
exec p_killspid
'資料庫名'
redis連線密碼和指定資料庫
臺伺服器上都快開啟200個redis例項了,看著就崩潰了。這麼做無非就是想讓不同型別的資料屬於不同的應用程式而彼此分開。那麼,redis有沒有什麼方法使不同的應用程式資料彼此分開同時又儲存在相同的例項上呢?就相當於mysql資料庫,不同的應用程式資料儲存在不同的資料庫下。redis下,資料庫是由乙個...
強制關閉MySQL資料庫
在使用mysql資料庫的過程中有時候會發現無法關閉資料庫,後來發現是因為使用者不是我本人開啟的,可以使用下面的命令列強制關閉 sudo usr local mysql support files mysql.server stop 或者使用命令列 sudo usr local mysql suppo...
指定資料庫讀寫分離操作
方式一 是檢視裡面用using方式可以進行指定到哪個資料讀寫 普通使用者 手動指定去某個資料庫取資料 方式二 寫配置檔案 class router1 指定到某個資料庫取資料 def db for read self,model,hints attempts to read auth models g...