# Manage SQL Database Root User

Root User คือ Database User ที่มีสิทธิ์การเข้าถึงและควบคุมสูงสุดของ Database เปรียบเสมือนผู้ดูแลระบบสูงสุด (administrator) ที่สามารถทำทุกสิ่งทุกอย่างได้ โดยไม่มีข้อจำกัด

### สิทธิ์ของการใช้งาน Root User

โดยทั่วไปสิทธิ์ของ Root User มีดังนี้

* **สิทธิ์การเข้าถึงเต็มรูปแบบ:** สามารถเข้าถึง Database, Database Schema, Table และข้อมูลทั้งหมด โดยไม่มีข้อจำกัด
* **สิทธิ์ในการจัดการ Database User:** สามารถสร้าง แก้ไข และลบ Database User อื่น รวมถึงการกำหนดสิทธิ์การเข้าถึงต่าง ๆ ด้วย
* **สิทธิ์ในการจัดการ Database Schema:** สามารถสร้าง แก้ไข และลบ Database Schema รวมถึงการจัดการโครงสร้างทั้งหมด
* **สิทธิ์ในการจัดการ Database. Instance:** สามารถตั้งค่าต่าง ๆ ของ Database Instance ในระดับ global รวมถึงการจัดการ plugins และการตั้งค่าความปลอดภัย
* **สิทธิ์ในการดำเนินการคำสั่ง SQL:** สามารถรันคำสั่ง SQL ได้ทุกคำสั่ง โดยไม่มีข้อจำกัด

### ข้อควรระวังและแนวทางการใช้งาน

**ข้อควรระวัง**

* เนื่องจาก Root User มีสิทธิ์การเข้าถึงที่กว้างขวาง การใช้งานจึงต้องมีความระมัดระวังเป็นอย่างยิ่ง การกระทำที่ผิดพลาดโดย Root User อาจนำไปสู่ความเสียหายต่อ Database หรือทำให้ระบบไม่ปลอดภัยได้
* หากมีการเปลี่ยนแปลง Database โดยใช้ Root User จะไม่สามารถตรวจสอบได้ผ่าน NCS ผู้ใช้งานจะต้องเข้าถึง Database ด้วยตนเองเพื่อตรวจสอบ&#x20;

**แนวทางการใช้งาน**

* **จำกัดการใช้งาน:** ใช้ Root User เท่าที่จำเป็นสำหรับการจัดการระบบในระดับสูง เช่น การตั้งค่าเริ่มต้น การแก้ไขปัญหาที่ต้องใช้สิทธิ์สูงสุด หรือการตั้งค่าอื่น ๆ ที่ยังไม่รองรับให้ทำผ่าน NCS เป็นต้น
* **สร้างผู้ใช้ที่มีสิทธิ์จำกัด:** ผู้ใช้งาน Root User ควรเป็นผู้ที่เชี่ยวชาญ โดยสำหรับการทำงานประจำวัน หรือการเข้าถึง Database เพื่อใช้งานทั่วไป ควรใช้งาน Database User อื่น ที่กำหนดสิทธิ์เฉพาะเจาะจงตามความจำเป็นของงานนั้น
* **รักษาความปลอดภัยของรหัสผ่าน:** เก็บรักษารหัสผ่านไว้อย่างปลอดภัย และเปลี่ยนรหัสผ่านอยู่เป็นประจำ เพื่อไม่ให้เกิดปัญหาความปลอดภัยตามมา
* **ตรวจสอบการใช้งาน:** ควรมีการตรวจสอบการใช้งาน Root User เพื่อป้องกันการเข้าถึงหรือการกระทำที่ไม่ได้รับอนุญาต

{% hint style="info" %}
ไม่มีการเก็บ Password ของ Root User ใน NCS เพื่อความปลอดภัยของผู้ใช้งาน
{% endhint %}

## คำสั่งที่ใช้จัดการ Root User มีดังต่อไปนี้

* [Enable Root User](/ncs-documents/database-as-a-service/sql-database/manage-sql-database-root-user/enable-root-user.md)
* [Reset Root User Password](/ncs-documents/database-as-a-service/sql-database/manage-sql-database-root-user/reset-root-user-password.md)

{% hint style="info" %}
หลังสั่งสร้าง Database Instance สำเร็จ จะยังไม่เปิดให้ใช้งาน Root User ผู้ใช้งานจะต้อง Enable Root User ก่อนถึงจะสามารถใช้งานได้
{% endhint %}

### การแสดงผล Root User

* **Root User เป็น Disabled**: หลังสั่งสร้าง Database Instance สำเร็จ จะยังไม่เปิดใช้งาน Root User
  * ที่หน้า Database Instance Detail แสดงคำสั่ง Enable

<figure><img src="/files/Nsi03hR7N7kaBGFKT5hR" alt=""><figcaption></figcaption></figure>

* **Root User เป็น Enabled**: เมื่อเปิดการใช้งาน Root User แล้ว
  * ที่หน้า Database Instance Detail แสดง Username: root และ คำสั่ง Reset Password

<figure><img src="/files/EG2IQV8ilvVndTIO5f1h" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-epc.gitbook.io/ncs-documents/database-as-a-service/sql-database/manage-sql-database-root-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
