

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 檢視 Lightsail 資料庫日誌和歷史記錄
<a name="amazon-lightsail-viewing-database-logs-and-history"></a>

您可以在 Amazon Lightsail 主控台中檢視資料庫日誌和變更歷程記錄。資料庫日誌提供有用的資訊，可協助您診斷資料庫的問題。同樣的，資料庫歷程記錄可顯示資料庫所做的變更，讓您掌握問題與最近變更之間的關聯。

**檢視您的資料庫日誌**

1. 登入 [Lightsail 主控台](https://lightsail.aws.amazon.com/)。

1. 在左側的導覽窗格中，選擇**資料庫**。

1. 選擇要檢視日誌的資料庫名稱。

1. 選擇 **Logs and history (日誌和歷程記錄)** 索引標籤。

   此頁面會顯示資料庫日誌和資料庫的變更歷程記錄。

1. 選擇資料庫日誌。下列資料庫日誌皆可供使用：

   **MySQL 資料庫日誌**
   + **錯誤日誌** – mysqld 啟動和關閉時間的記錄。它還包含伺服器啟動、關閉及運作時的診斷訊息，例如錯誤、警告和備註。如需詳細資訊，請參閱 [MySQL 5.6](https://dev.mysql.com/doc/refman/5.6/en/keywords.html)、[MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/keywords.html) 或 [MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/keywords.html) 文件中的錯誤日誌文章。
   + **一般日誌** — mysqld 的一般作業記錄。用戶端連線或中斷連線時，伺服器會將資訊寫入此日誌​，並記錄從用戶端接收的各個 SQL 陳述式。如需詳細資訊，請參閱 [MySQL 5.6](https://dev.mysql.com/doc/refman/5.6/en/keywords.html)、[MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/keywords.html) 或 [MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/keywords.html) 文件中的一般查詢日誌文章。
   + **​慢查詢日誌** — 執行時間超過 long\_query\_time 秒數，且至少有 min\_examined\_row\_limit 列需要檢查之 SQL 陳述式的記錄。如需詳細資訊，請參閱 [MySQL 5.6](https://dev.mysql.com/doc/refman/5.6/en/keywords.html)、[MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/keywords.html) 或 [MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/keywords.html) 文件中的慢查詢日誌文章。
**注意**  
MySQL 資料庫預設會停用一般日誌和慢查詢日誌。藉由更新一些資料庫參數，您就可以啟用這些日誌，並開始收集資料。如需詳細資訊，請參閱[在 Amazon Lightsail 中啟用 MySQL 資料庫一般與慢速查詢日誌](amazon-lightsail-enabling-mysql-general-and-slow-query-logs)。

   **PostgreSQL 資料庫日誌**
   + **Postgres 日誌** – 資料庫啟動和關閉時間的記錄。該日誌可能也會包含診斷資訊，例如資料庫啟動、關閉和執行期間所出現的錯誤、警告、通知和偵錯訊息。如需詳細資訊，請參閱 [PostgreSQL 9.6](https://www.postgresql.org/docs/9.6/runtime-config-logging.html)、[PostgreSQL 10](https://www.postgresql.org/docs/10/runtime-config-logging.html)、[PostgreSQL 11](https://www.postgresql.org/docs/11/runtime-config-logging.html) 或 [PostgreSQL 12](https://www.postgresql.org/docs/12/runtime-config-logging.html) 文件中說明錯誤回報和記錄的文章。

**Topics**
+ [MySQL 查詢日誌](amazon-lightsail-enabling-mysql-general-and-slow-query-logs.md)