Skip to content

MySQL 凭据#

¥MySQL credentials

你可以使用以下凭据验证以下节点:

¥You can use these credentials to authenticate the following nodes:

¥Agent

Agent node users

代理节点不支持 SSH 隧道。

¥The Agent node doesn't support SSH tunnels.

先决条件#

¥Prerequisites

MySQL 服务器数据库上创建用户账户。

¥Create a user account on a MySQL server database.

支持的身份验证方法#

¥Supported authentication methods

  • 数据库连接

¥Database connection

相关资源#

¥Related resources

有关服务的更多信息,请参阅 MySQL 文档

¥Refer to MySQL's documentation for more information about the service.

使用数据库连接#

¥Using database connection

要配置此凭据,你需要:

¥To configure this credential, you'll need:

  • 服务器主机:数据库的主机名或 IP 地址。

¥The server Host: The database's host name or IP address.

  • 数据库名称。

¥The Database name.

  • 用户名

¥A User name.

  • 该用户的密码。

¥A Password for that user.

  • MySQL 服务器使用的端口号。

¥The Port number used by the MySQL server.

  • 连接超时:初始数据库连接超时前的毫秒数。

¥Connect Timeout: The number of milliseconds during the initial database connection before a timeout occurs.

  • SSL:如果你的数据库使用 SSL,请启用此选项并添加 SSL 证书的详细信息。

¥SSL: If your database is using SSL, turn this on and add details for the SSL certificate.

  • SSH 隧道:选择是否通过 SSH 隧道连接。SSH 隧道允许未加密的流量通过加密连接传输,并允许对受防火墙保护、无法直接访问的服务器进行授权的远程访问。

¥SSH Tunnel: Choose whether to connect over an SSH tunnel. An SSH tunnel lets un-encrypted traffic pass over an encrypted connection and enables authorized remote access to servers protected from outside connections by a firewall.

要设置数据库连接凭据:

¥To set up your database connection credential:

  1. 在你的 n8n 凭据中,将数据库主机名作为“主机”输入。运行以下查询以确认主机名:

¥Enter your database's hostname as the Host in your n8n credential. Run this query to confirm the hostname:

1
SHOW VARIABLES WHERE Variable_name = 'hostname';
  1. 在你的 n8n 凭据中,将数据库名称作为“数据库”输入。运行以下查询以确认数据库名称:

¥Enter your database's name as the Database in your n8n credential. Run this query to confirm the database name:

1
SHOW DATABASES;
  1. 输入数据库中用户的用户名。该用户应拥有 n8n 执行任何操作所需的相应权限。

¥Enter the username of a User in the database. This user should have appropriate permissions for whatever actions you want n8n to perform.

  1. 输入该用户的密码。

¥Enter the Password for that user.

  1. 输入 MySQL 服务器使用的端口号(默认为 3306)。运行以下查询以确认端口号:

¥Enter the Port number used by the MySQL server (default is 3306). Run this query to confirm the port number:

1
SHOW VARIABLES WHERE Variable_name = 'port';
  1. 请输入你希望节点使用的连接超时时间。连接超时是指节点在初始数据库连接期间等待超时的毫秒数。n8n 默认使用 10000 版本,这是 MySQL 的默认值,即 10 秒。如果你想匹配数据库中的 connect_timeout,请运行以下查询获取它,然后将其乘以 1000,再输入到 n8n 中:

¥Enter the Connect Timeout you'd like the node to use. The Connect Timeout is the number of milliseconds during the initial database connection the node should wait before timing out. n8n defaults to 10000 which is the default used by MySQL of 10 seconds. If you want to match your database's connect_timeout, run this query to get it, then multiply by 1000 before entering it in n8n:

1
SHOW VARIABLES WHERE Variable_name = 'connect_timeout';
  1. 如果你的数据库使用 SSL,并且你希望为连接使用 SSL,请在凭据中启用此选项。如果启用 LDAP,请在以下字段中输入 MySQL SSL 证书信息:

¥If your database uses SSL and you'd like to use SSL for the connection, turn this option on in the credential. If you turn it on, enter the information from your MySQL SSL certificate in these fields: 1. 在“CA 证书”字段中输入 ca.pem 文件的内容。

1
  ¥Enter the `ca.pem` file contents in the **CA Certificate** field.
  1. 在“客户端私钥”字段中输入 client-key.pem 文件内容。

    ¥Enter the client-key.pem file contents in the Client Private Key field. 3. 在“客户端证书”字段中输入 client-cert.pem 文件的内容。

    ¥Enter the client-cert.pem file contents in the Client Certificate field.

  2. 如果你想使用 SSH 隧道进行连接,请在凭据中启用此选项。否则,请跳过此步骤。如果启用二进制文件:

¥If you want to use SSH Tunnel for the connection, turn this option on in the credential. Otherwise, skip it. If you turn it on: 1. 选择“SSH 身份验证方式”以设置要构建的 SSH 隧道类型:

1
2
3
4
5
6
7
8
9
  ¥Select the **SSH Authenticate with** to set the SSH Tunnel type to build:

  * 如果你想使用密码连接到 SSH,请选择“密码”。

    ¥Select **Password** if you want to connect to SSH using a password.

  * 如果你想使用身份文件(私钥)和密码短语连接到 SSH,请选择“私钥”。

    ¥Select **Private Key** if you want to connect to SSH using an identity file (private key) and a passphrase.
  1. 输入 SSH 主机。n8n 使用此主机创建格式如下的 SSH URI:[user@]host:port

    ¥Enter the SSH Host. n8n uses this host to create the SSH URI formatted as: [user@]host:port. 3. 输入 SSH 端口。n8n 使用此端口创建格式如下的 SSH URI:[user@]host:port

    ¥Enter the SSH Port. n8n uses this port to create the SSH URI formatted as: [user@]host:port. 4. 输入要连接的 SSH 用户名。n8n 使用此用户创建格式如下的 SSH URI:[user@]host:port

    ¥Enter the SSH User to connect with. n8n uses this user to create the SSH URI formatted as: [user@]host:port. 5. 如果你选择“SSH 身份验证密码”,请添加 SSH 密码。

    ¥If you selected Password for SSH Authenticate with, add the SSH Password. 6. 如果你选择“SSH 身份验证私钥”:

    ¥If you selected Private Key for SSH Authenticate with: 1. 添加用于 SSH 的私钥或身份文件的内容。这与在 MySQL 中使用带有 shell-connect() 命令的 ssh-identity-file 选项相同。

    1
     ¥Add the contents of the **Private Key** or identity file used for SSH. This is the same as using the `ssh-identity-file` option with the `shell-connect()` command in MySQL.
    
    1. 如果私钥是在创建时设置了密码的,请输入该密码。这与在 MySQL 中使用带有 shell-connect() 命令的 ssh-identity-pass 选项相同。如果私钥没有密码,请将此字段留空。

      ¥If the Private Key was created with a passphrase, enter that Passphrase. This is the same as using the ssh-identity-pass option with the shell-connect() command in MySQL. If the Private Key has no passphrase, leave this field blank.

有关在 MySQL 中使用 SSL 证书的更多信息,请参阅 MySQL | 创建 SSL 和 RSA 证书及密钥。有关在 MySQL 中使用 SSH 隧道的更多信息,请参阅 MySQL |使用 SSH 隧道

¥Refer to MySQL | Creating SSL and RSA Certificates and Keys for more information on working with SSL certificates in MySQL. Refer to MySQL | Using an SSH Tunnel for more information on working with SSH tunnels in MySQL.