March 20, 2024 | Created
Vue 與 .NET 的邂逅|05 變更 SQL Server 驗證方式
為何需要變更驗證方式
在《01 建立 .NET 相關環境》- 測試 SQL Server 運作 的章節中,我們安裝好 SQL Server 及 SSMS 後,有使用 Windows 驗證登入,測試是否可以成功連線。
不過 Windows 驗證是以 Windows 登入的使用者作為身份,無法提供外部的應用程式訪問。
因此,我們需要改使用 SQL Server 驗證的方式,才能夠管理外部訪問的存取權限。
將 Windows 驗證 改為 SQL Server 驗證
使用 Windows 驗證登入後,在物件總管的項目上,按「右鍵」並選擇「屬性」
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
接著左側「選取頁面欄」,點選並切換至「安全性」頁面
並在「伺服器驗證」的項目下,選擇「SQL Server 及 Windows 驗證模式」並在右下角按「確定」使之生效
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
回到物件總管的項目,展開次項目:「安全性 > 登入」
選擇 「sa」,按「右鍵」並選擇「屬性」
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
接下來會針對左側「選取頁面欄」的「一般」及「狀態」進行設定
在一般頁面,我們可設定登入的密碼。
值得注意的是,正式使用時,建議勾選「強制執行密碼原則」與「強制執行密碼逾期」,以維持資訊安全
不過現在作為練習,就先不勾選,密碼輸入簡單易記的文字或數字即可
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
在狀態頁面,改為「啟用」登入功能
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
完成以上步驟,就算完成設定,接下來就測試看看設定是否正常運作
重啟 SQL Server 服務並中斷連線
在 Windows 應用程式開啟「搜尋」,輸入「服務」並開啟
找到 SQL Server(MSSQLSERVER),點選「右鍵」選擇「重新啟動」
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
重啟後,在物件總管的項目上,按「右鍵」並選擇「中斷連接」
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
以 SQL Server 驗證方式登入
按「檔案 > 連接物件總管」
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
驗證方式選擇「SQL Server 驗證」
帳號輸入「sa」
密碼則是剛剛更改的密碼
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
前述過程若出現以下錯誤訊息
使用者'sa'的登入失敗。(Microsoft SQL Server,錯誤: 18456)
請返回上方「重啟 SQL Server 服務並中斷連線」節點,重啟服務。
若成功使用 SQL Server 驗證,可看到物件總管的項目名稱後方,會出現 「sa」 字樣
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Reference
系列:Vue 與 .NET 的邂逅
上一篇:04 建立 Vue & .Net 專案
下一篇:
文章若有任何錯誤,還請不吝給予留言指正,謝謝大家!