> For the complete documentation index, see [llms.txt](https://docs.plura.io/ja/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.plura.io/ja/agents/siem/uplc/mysql-error.md).

# MySQL error

{% hint style="info" %}
アプリケーション:MySQL ErrorログとSlow-Queryログ収集のための設定
{% endhint %}

## 1. アプリケーションログ収集設定 <a href="#id-1" id="id-1"></a>

1-1. 設定経路

* システム > システム管理 > 対象選択 > 設定タブの移動 > 設定ボタンをクリックします。

<figure><img src="/files/6I5h3zArTeVpgJnrL4B9" alt=""><figcaption></figcaption></figure>

1-2.アプリケーションソースログ収集設定の有効化

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

1-3. パス > 設定ボタンをクリック

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

1-4. タグの選択とパス入力

* MySQL ErrorログとSlow-Queryログパスを入力します。

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

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

1-5. 入力情報の確認

* タグが正常に登録されていることを確認し、修正ボタンをクリックします。

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

* タグ登録方法
  * アプリケーション ログ収集設定のタグを登録できます。
  * パス:管理 > リスト > アプリケーション タグ

* 設定ボタンをクリックします。

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

* 登録ボタンをクリックして、登録したいタグを入力します。

<figure><img src="/files/5zsEseSd1YmRIkGGFyO6" alt=""><figcaption></figcaption></figure>

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

***

## 2. MySQL – SLOW QUERY 設定 <a href="#id-2" id="id-2"></a>

2.1 設定

```
vi /etc/my.cnf
```

```
[mysqld]
slow_query_log = 1
slow_query_log_file = /var/log/mysql-slow.log
long_query_time = 3
```

2.2 ログ ファイルの作成と権限設定

```
touch /var/log/mysql-slow.log
chown mysql.mysql /var/log/mysql-slow.log
```

2.3 権限確認

```
ls -aZ /var/log/mysql*
```

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

2.4 mysql restart

```
systemctl restart mysqld
```

2.5 活性化確認

```
mysql> show variables like ‘slow_query_%’;
```

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

2.6 mysql query ロギング追加(選択)

```
vi /etc/my.cnf
```

```
[mysqld]
general_log_file = /var/log/general.log
general_log = 1
```

```
touch /var/log/general.log
chown mysql.mysql /var/log/general.log
systemctl restart mysqld
```

2.7 権限の問題でログが記録されない場合 safe start

```
./mysqld_safe &
```

## 3. ログ確認 <a href="#id-3" id="id-3"></a>

* MySQL ErrorまたはSlow Queryログ発生後、アプリケーションログでMySQL関連ログを確認します。 登録したタグ名で検索が可能です。

## 参考マニュアル <a href="#id-4" id="id-4"></a>

> [https://docs.plura.io/ja/faq/comm/uploadapp](https://docs.plura.io/ja/faq/common/uploadapp)
