# 常見錯誤

## 1. 使用MySQL資料庫，出現500 Internal Server Error

類似錯誤訊息如下：

* populate() isn't reentrant
* MySQLdb.\_exceptions.OperationalError: (2059, NULL)

### 解決辦法：

由於django目前還不支持mysql8.0的caching\_sha2\_password加密方式，因此需修改為mysql\_native\_password加密方法

打開mysql指令視窗，輸入指令

```
ALTER USER '<帳號>'@'localhost' IDENTIFIED BY '<帳號>' PASSWORD EXPIRE NEVER;
```

更新密碼

```
ALTER USER '<帳號>'@'localhost' IDENTIFIED WITH mysql_native_password BY '<密碼>';
```

修改後重啟服務即可

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

## 2. 使用SQL Server資料庫，於安裝或更新過程出現error.log

查看error.log出現以下類似錯誤訊息：

* SQL Server v16 is not supported.
* raise FullResultSet

### 解決辦法：

由於 django4.2 及 SQL Server 2022 後，原先使用的mssql相關套件已不支援，請按照以下步驟執行：

#### 下載套件

請至Python資料夾下安裝所需套件：

若為Windows版本路徑為 `C:\Program Files\OMFLOW Server\Python`

```
python.exe -m pip install mssql-django -t Lib\site-packages

```

Linux版本則進入虛擬Python環境

```
pip install mssql-django

```

#### 修改settings.py

Windows版本路徑為 `C:\Program Files\OMFLOW Server\omflow\omflow\settings.py`

Linux版本路徑為 `/opt/omflow/server/omflow/settings.py`

```
#將ENGINE參數值改為mssql
DATABASES = {"default": {"ENGINE": "sql_server.pyodbc","NAME":...後面略
#改為
DATABASES = {"default": {"ENGINE": "mssql","NAME":......後面略
```

#### 重新執行更新檔

## 3. 使用Domain或外部IP連線回傳CSRF(403)錯誤 - 1.2.1 New

### 解決辦法：

Django4.2 版本後使用 Domain 進行連線需要額外設定 **CSRF\_TRUSTED\_ORIGINS** 參數

#### 修改settings.py

Windows版本路徑為 `C:\Program Files\OMFLOW Server\omflow\omflow\settings.py`

Linux版本路徑為 `/opt/omflow/server/omflow/settings.py`

```
DEBUG = False

#新增以下設定，並將網址替換為使用的Domain
CSRF_TRUSTED_ORIGINS = [
        'https://*.example1.com',
        'https://*.example2.com',
        ...
    ]
```

#### 重新執行更新檔


---

# 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://doc.omflow.com.tw/id-2/2-13-1.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.
