MySQL credentials#
You can use these credentials to authenticate the following nodes:
Agent node users
The Agent node doesn't support SSH tunnels.
Prerequisites#
Create a user account on a MySQL server database.
Supported authentication methods#
- Database connection
Related resources#
Refer to MySQL's documentation for more information about the service.
Using database connection#
To configure this credential, you'll need:
- The server Host: The database's host name or IP address.
- The Database name.
- A User name.
- A Password for that user.
- The Port number used by the MySQL server.
- Connect Timeout: The number of milliseconds during the initial database connection before a timeout occurs.
- SSL: If your database is using SSL, turn this on and add details for the SSL certificate.
- 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:
-
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';
-
Enter your database's name as the Database in your n8n credential. Run this query to confirm the database name:
1
SHOW DATABASES;
-
Enter the username of a User in the database. This user should have appropriate permissions for whatever actions you want n8n to perform.
- Enter the Password for that user.
-
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';
-
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
1000
which is the default used by MySQL of 10 seconds. If you want to match your database'sconnect_timeout
, run this query to get it, then multiply by 100 before entering it in n8n:1
SHOW VARIABLES WHERE Variable_name = 'connect_timeout';
-
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:
- Enter the
ca.pem
file contents in the CA Certificate field. - Enter the
client-key.pem
file contents in the Client Private Key field. - Enter the
client-cert.pem
file contents in the Client Certificate field.
- Enter the
- 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:
- Select the SSH Authenticate with to set the SSH Tunnel type to build:
- Select Password if you want to connect to SSH using a password.
- Select Private Key if you want to connect to SSH using an identity file (private key) and a passphrase.
- Enter the SSH Host. n8n uses this host to create the SSH URI formatted as:
[user@]host:port
. - Enter the SSH Port. n8n uses this port to create the SSH URI formatted as:
[user@]host:port
. - Enter the SSH User to connect with. n8n uses this user to create the SSH URI formatted as:
[user@]host:port
. - If you selected Password for SSH Authenticate with, add the SSH Password.
- If you selected Private Key for SSH Authenticate with:
- 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 theshell-connect()
command in MySQL. - If the Private Key was created with a passphrase, enter that Passphrase. This is the same as using the
ssh-identity-pass
option with theshell-connect()
command in MySQL. If the Private Key has no passphrase, leave this field blank.
- Add the contents of the Private Key or identity file used for SSH. This is the same as using the
- Select the SSH Authenticate with to set the SSH Tunnel type to build:
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.