{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"MySQL Import Integration CLI","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"mysql-import-integration-cli","__idx":0},"children":["MySQL Import Integration CLI"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure コンソールが利用できない場合やご利用いただけない場合でも、CLIからMySQLデータコネクタを使用できます。以下の手順では、CLIを使用してデータをインポートする方法を説明します。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"前提条件","__idx":1},"children":["前提条件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Dataの基本的な知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["MySQLの基本的な知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Dataから到達可能なMySQLインスタンス"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MySQL Community Server 5.6および5.7を使用していてSSLを使用したい場合は、コネクタの基盤となるライブラリとの互換性の問題を解決するために、パラメータenabledTLSProtocolsとTLSv1.2を設定してください。他のMySQLバージョンでは、統合は自動的に最高のTLSバージョンを使用しようとします。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"tdコマンド-v0119以降のインストール","__idx":2},"children":["'td'コマンド v0.11.9以降のインストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["最新の",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://toolbelt.treasuredata.com/"},"children":["TD Toolbelt"]},"をインストールしてください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"設定ファイルの作成","__idx":3},"children":["設定ファイルの作成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MySQLアクセス情報を含む設定ファイル（例：load.yml）を以下のように準備してください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: mysql\n  host: mysql_host_name\n  port: 3306\n  user: test_user\n  password: test_password\n  database: test_database\n  table: test_table\n  select: \"*\"\nout:\n  mode: replace\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この例では、テーブル内のすべてのレコードをダンプします。",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/embulk/embulk-input-jdbc/tree/master/embulk-input-mysql"},"children":["追加パラメータ"]},"を使用して、より詳細な制御が可能です。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SSLオプションを使用する場合は、以下のオプションを使用してください："]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["requireSSL"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["useSSL"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["verifyServerCertificate"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: mysql\n  host: mysql_host_name\n  port: 3306\n  user: test_user\n  password: test_password\n  options:\n    requireSSL: true\n    useSSL: true\n    verifyServerCertificate: false\n  database: test_database\n  table: test_table\n  select: \"*\"\nout:\n  mode: replace\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["利用可能なoutモードの詳細については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/int/mysql-import-integration"},"children":["付録"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"データのプレビューオプション","__idx":4},"children":["データのプレビュー（オプション）"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["td connector:previewコマンドを使用して、インポートされるデータをプレビューできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:preview load.yml\n+---------+--------------+----------------------------------+------------+---------------------------+\n| id:long | name:string  | description:string               | price:long | created_at:timestamp      |\n+---------+--------------+----------------------------------+------------+---------------------------+\n| 1       | \"item name1\" | \"26e3c3625366591bc2ffc6e262976e\" | 2419       | \"2014-02-16 13:01:06 UTC\" |\n| 2       | \"item name2\" | \"3e9dd9474dacb78afd607f9e0a3366\" | 1298       | \"2014-05-24 13:59:26 UTC\" |\n| 3       | \"item name3\" | \"9b6c9e4a140284d3951681e9e047f6\" | 9084       | \"2014-06-21 00:18:21 UTC\" |\n| 4       | \"item name4\" | \"a11faf5e63c1b02a3d4c2b5cbb7331\" | 669        | \"2014-05-02 03:44:08 UTC\" |\n| 6       | \"item name6\" | \"6aa15471c373ddc8a6469e1c918f98\" | 3556       | \"2014-03-29 08:30:23 UTC\" |\n+---------+--------------+----------------------------------+------------+---------------------------+\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ロードジョブの実行","__idx":5},"children":["ロードジョブの実行"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ロードジョブを送信します。データサイズによっては数時間かかる場合があります。ユーザーは、データが保存されているデータベースとテーブルを指定する必要があります。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataのストレージは時間でパーティション分割されているため（",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench"},"children":["アーキテクチャ"]},"も参照）、--time-columnオプションを指定することを推奨します。このオプションを指定しない場合、Data Connectorは最初のlong型またはtimestamp型のカラムをパーティショニング時間として選択します。--time-columnで指定するカラムの型は、long型またはtimestamp型のいずれかである必要があります。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["データに時間カラムがない場合は、add_timeフィルタオプションを使用して追加できます。詳細は",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/smart/project-product-documentation/add_time-filter-function"},"children":["add_timeフィルタプラグイン"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:issue load.yml --database td_sample_db --table td_sample_table --time-column created_at\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["上記のコマンドは、*database(td_sample_db)",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["と"]},"table(td_sample_table)*を既に作成していることを前提としています。TDにdatabaseまたはtableが存在しない場合、このコマンドは成功しません。Treasure コンソールを使用してdatabaseとtableを作成するか、td connector:issueコマンドで--auto-create-tableオプションを使用して、databaseとtableを自動作成してください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:issue load.yml --database td_sample_db --table td_sample_table --time-column created_at --auto-create-table\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["\"--time-column\"オプションで、Time Format列を\"Partitioning Key\"に割り当てることができます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"scheduled-execution","__idx":6},"children":["Scheduled Execution"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["高可用性スケジューラを使用して、定期的なMySQLインポートのためのData Connector実行をスケジュールできます。この機能を使用することで、ローカルデータセンターにcronデーモンを設置する必要がなくなります。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"incremental-load","__idx":7},"children":["Incremental load"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["incremental_columnsパラメータにテーブルのカラムを指定することで、レコードを段階的にロードできます。オプションで、last_recordパラメータに初期値を指定することもできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: mysql\n  options: {useLegacyDatetimeCode: false}\n  host: mysql_host_name\n  port: 3306\n  user: test_user\n  password: test_password\n  database: test_database\n  table: test_table\n  incremental: true\n  incremental_columns: [id, created_at]\n  last_record: [10000, '2014-02-16T13:01:06.000000Z']\nout:\n  mode: append\n  exec: {}\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["フルテーブルスキャンを避けるために、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["incremental\\_columns:"]},"オプションを使用して関連するカラムにインデックスを作成してください。"," ","この例では、以下のインデックスを作成します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"CREATE INDEX embulk_incremental_loading_index ON test_table (id, created_at);\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Connectorは自動的にクエリを作成し、値をソートします。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"-- when last_record wasn't given\nSELECT * FROM(\n    ...original query is here\n)\nORDER BY id, created_at\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"-- when last_record was given\nSELECT * FROM(\n    ...original query is here\n)\nWHERE id > 10000 OR (id = 10000 AND created_at > '2014-02-16T13:01:06.000000Z')\nORDER BY id, created_at\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Connectorは自動的にlast_recordを取得し、次のスケジュール実行時に使用します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"in:\n  type: mysql\n  options:\n    useLegacyDatetimeCode: false\n  ...\nout:\n  ...\n\nConfig Diff\n---\nin:\n  last_record:\n  - 20000\n  - '2015-06-16T16:32:14.000000Z'\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["incremental: true"]},"を設定すると、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["query"]},"オプションは使用できません。"," ","incremental_columnsとしてサポートされているのは、文字列、整数、datetimeおよびtimestamp型のみです。"," ","datetime/timestamp型のカラムをincremental_columnsとして使用する場合は、GUIでJDBC接続オプションとして、または設定ファイルの",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["options"]},"として",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["useLegacyDatetimeCode: false"]},"を設定してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"スケジュールの作成","__idx":8},"children":["スケジュールの作成"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["新しいスケジュールは、td connector:createコマンドを使用して作成できます。スケジュール名、cron形式のスケジュール、データの保存先となるデータベースとテーブル、およびData Connector設定ファイルが必要です。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:create \\\n    daily_mysql_import \\\n    \"10 0 * * *\" \\\n    td_sample_db \\\n    td_sample_table \\\n    load.yml\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cron"]},"パラメータは、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@hourly"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@daily"]},"、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@monthly"]},"の3つのオプションも受け付けます。"," ","デフォルトでは、スケジュールはUTCタイムゾーンで設定されます。-tまたは--timezoneオプションを使用して、任意のタイムゾーンでスケジュールを設定できます。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--timezone"]},"オプションは、'Asia/Tokyo'や'America/Los_Angeles'などの拡張タイムゾーン形式のみをサポートしています。PST、CSTなどのタイムゾーン略語は*サポートされておらず*、予期しないスケジュールになる可能性があります。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"スケジュールの一覧表示","__idx":9},"children":["スケジュールの一覧表示"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["現在スケジュールされているエントリの一覧は、td connector:listで確認できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:list\n+--------------------+--------------+----------+-------+--------------+-----------------+-------------------------+\n| Name               | Cron         | Timezone | Delay | Database     | Table           | Config                  |\n+--------------------+--------------+----------+-------+--------------+-----------------+-------------------------+\n| daily_mysql_import | 10 0 * * *   | UTC      | 0     | td_sample_db | td_sample_table | {\"type\"=>\"mysql\", ... } |\n+--------------------+--------------+----------+-------+--------------+-----------------+-------------------------+\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"スケジュールの詳細表示","__idx":10},"children":["スケジュールの詳細表示"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td connector:show"]},"は、スケジュールエントリの実行設定を表示します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"% td connector:show daily_mysql_import\nName     : daily_mysql_import\nCron     : 10 0 * * *\nTimezone : UTC\nDelay    : 0\nDatabase : td_sample_db\nTable    : td_sample_table\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["td connector:historyは、スケジュールエントリの実行履歴を表示します。各実行の結果を調査するには、td job jobidを使用してください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"% td connector:history daily_mysql_import\n+--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+\n| JobID  | Status  | Records | Database     | Table           | Priority | Started                   | Duration |\n+--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+\n| 578066 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-18 00:10:05 +0000 | 160      |\n| 577968 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-17 00:10:07 +0000 | 161      |\n| 577914 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-16 00:10:03 +0000 | 152      |\n| 577872 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-15 00:10:04 +0000 | 163      |\n| 577810 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-14 00:10:04 +0000 | 164      |\n| 577766 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-13 00:10:04 +0000 | 155      |\n| 577710 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-12 00:10:05 +0000 | 156      |\n| 577610 | success | 10000   | td_sample_db | td_sample_table | 0        | 2015-04-11 00:10:04 +0000 | 157      |\n+--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+\n8 rows in set\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"スケジュールの削除","__idx":11},"children":["スケジュールの削除"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td connector:delete"]},"は、スケジュールを削除します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$ td connector:delete daily_mysql_import\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"付録","__idx":12},"children":["付録"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"outプラグインのモード","__idx":13},"children":["outプラグインのモード"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["load.ymlのoutセクションでファイルインポートモードを指定できます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["たとえば、Treasure Data内の既存のテーブルにデータを追加するか、データを置き換えるかを選択できます。"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["モード"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["説明"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["例"]}]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Append"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["レコードがターゲットテーブルに追加されます。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["in:   ... out:   mode: append"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Always Replace"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ターゲットテーブルのデータを置き換えます。ターゲットテーブルに対して手動で行われたスキーマ変更は保持されます。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["in:   ... out:   mode: replace"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Replace on new data"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["インポートする新しいデータがある場合にのみ、ターゲットテーブルのデータを置き換えます。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["in:   ... out:   mode: replace_on_new_data"]}]}]}]}]}]}]},"headings":[{"value":"MySQL Import Integration CLI","id":"mysql-import-integration-cli","depth":1},{"value":"前提条件","id":"前提条件","depth":2},{"value":"'td'コマンド v0.11.9以降のインストール","id":"tdコマンド-v0119以降のインストール","depth":2},{"value":"設定ファイルの作成","id":"設定ファイルの作成","depth":2},{"value":"データのプレビュー（オプション）","id":"データのプレビューオプション","depth":2},{"value":"ロードジョブの実行","id":"ロードジョブの実行","depth":2},{"value":"Scheduled Execution","id":"scheduled-execution","depth":2},{"value":"Incremental load","id":"incremental-load","depth":3},{"value":"スケジュールの作成","id":"スケジュールの作成","depth":2},{"value":"スケジュールの一覧表示","id":"スケジュールの一覧表示","depth":2},{"value":"スケジュールの詳細表示","id":"スケジュールの詳細表示","depth":2},{"value":"スケジュールの削除","id":"スケジュールの削除","depth":2},{"value":"付録","id":"付録","depth":1},{"value":"outプラグインのモード","id":"outプラグインのモード","depth":2}],"frontmatter":{"seo":{"title":"MySQL Import Integration CLI"}},"lastModified":"2026-06-01T09:34:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/int/mysql-import-integration-cli","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}