> ## Documentation Index
> Fetch the complete documentation index at: https://docs.exploratory.io/llms.txt
> Use this file to discover all available pages before exploring further.

# MariaDB (MySQL) データベースからデータをインポートする

MariaDB (MySQL) データベースからExploratoryに素早くデータをインポートすることができます。

## 1. 使用するデータコネクションを作成する

[この手順](https://docs.exploratory.io/en/import/connection.html.md)に従って、データコネクションを作成します。

* SSL接続かどうかは自動的に判別されます。

## 2. MariaDB (MySQL) インポートダイアログを開く

データフレームの横の「＋」ボタンをクリックし、「データベースデータ」を選択します。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/import-db.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=223552e13aaf8637788da01314e2b321)

MariaDB (MySQL) をクリックします。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/mysql.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=6f07ce9d128d559e05026b1da8d01aa6)

## 3. インポート

1. 左のダイアログボックスから接続を選択します。

2. 入力フィールドにクエリを記述します。

3. "実行 "ボタンをクリックします。すると、データのプレビューが表示されます。

4. "保存"ボタンをクリックします。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/mysql-import.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=3c688eb75e6d32705c764746406af372)

## 4. SQLでパラメーターを使用する

まず、SQLデータインポートダイアログの「パラメーター」リンクをクリックします。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/add_parameter.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=b89b043fecd54a0cd2a67fbbe27c0394)

次に、パラメーターを定義し、\[保存]ボタンをクリックします。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/define_parameter.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=5b18fbed3e5994b9366967e8fb4f41bf)

最後に、クエリ内の変数名を@{}で囲むと、以下のようになります。

```
select *
from airline_2016_01
where carrier = @{carrier}
```

を入力すると、以下のようなパラメーターが表示されます。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/insert_param_in_query.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=4150df940c59d8fb22d85897f5c8f6bb)のようになります。

詳しくはこちらの[ブログ記事](https://exploratory.io/note/kanaugust/An-Introduction-to-Parameter-in-Exploratory-WCO4Vgn7HJ)をご覧ください。

## 5. AWSセキュリティグループの設定 (Amazon RDSのみ)

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/aws-security-group.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=c0c1775917509cf1252ab4a9c36bb289)

MySQLのデータベースとしてAmazon RDSを使用していて、データベース接続エラーが発生した場合、AWSコンソールにアクセスし、MySQLデータベースインスタンスに関連付けられたDBセキュリティグループのルール (インバウンド) にクライアントPCのIPアドレスが追加されていることを確認してください。

## 6. 実際の行数

パフォーマンスの観点から、クエリ全体を再実行しないと取得できない、実際の行数を表示しないようにしました。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/sql_number_of_rows.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=da1ad82d42a81df0744d4dbf45f6d9a4)

それでもクエリの結果の実数を表示したい場合は、システム設定により表示させることができます。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/num_of_rows_config_menu.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=28cb3b60e8fb0cbf75446c99c84cfc53)

そして、"SQLデータインポートダイアログで実際の行数を表示"を「はい」に設定します。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/num_of_rows_config.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=66742c51a94f27d604e244fe31a7b4c3)

これにより、以下のように実際の行数が表示されます。

![](https://mintcdn.com/exploratory-inc/_cHetG8yIT5gmGiQ/ja/import/images/actual_num_of_rows.png?fit=max\&auto=format\&n=_cHetG8yIT5gmGiQ\&q=85\&s=51a79e66d3390f87916c4b08e3cbb4e5)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.