Connect
Establishes a connection to a MySQL database server.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Credentials - The MySQL database credentials containing server, port, database, username, and password. Use a Database credential (Category 5) from the vault.
- Parameters - Additional connection string parameters (optional). For example:
SslMode=none;AllowPublicKeyRetrieval=true
Options
- None
Output
- Connection Id - A unique identifier for the established database connection. Store this value to use in subsequent MySQL operations.
How It Works
The Connect node establishes a connection to a MySQL database using the provided credentials. When executed, the node:
- Validates the provided database credentials
- Extracts server, port, database, username, and password from the credential
- Constructs a MySQL connection string
- Appends any additional connection parameters if provided
- Creates and opens a new MySqlConnection
- Generates a unique connection ID (GUID)
- Stores the connection in an internal connections dictionary
- Returns the connection ID as output
Requirements
- Valid MySQL database credentials with the following fields:
- server - Hostname or IP address of the MySQL server
- port - Port number (default: 3306)
- database - Database name (optional)
- username - MySQL username (required)
- password - MySQL password
- MySQL server must be accessible from the robot
- Proper network connectivity and firewall rules
Error Handling
The node will return specific errors in the following cases:
- ErrCredentials - No credentials provided, or missing required fields (username or server)
- ErrConnection - Cannot connect to MySQL server (invalid credentials, server not reachable, network issues)
Usage Examples
Basic Connection
// Store the connection ID from the Connect node output
const connId = $item.conn_id;
// Use this connection ID in subsequent Query, Insert, etc. nodes
Connection with SSL Disabled
When connecting to local MySQL servers or development environments, you may need to disable SSL:
Parameters: SslMode=none;AllowPublicKeyRetrieval=true
Connection with Custom Port
Configure your Database credential with:
- Server: localhost
- Port: 3307
- Database: myapp_db
- Username: myapp_user
- Password: secure_password
Common Use Cases
- Web Scraping with Database Storage - Connect to MySQL to store scraped data
- Business Automation - Query customer data, update orders, manage inventory
- Report Generation - Extract data from MySQL for automated reporting
- Data Migration - Move data between systems using MySQL as source or destination
- Scheduled Jobs - Automate database maintenance, backups, and cleanup tasks
Tips for Effective Use
- Store Connection ID - Always store the connection ID in a variable for reuse across multiple database operations
- Use Vault Credentials - Never hardcode database credentials; use the vault's Database credential type
- Connection Pooling - Reuse the same connection ID for multiple operations to improve performance
- Proper Cleanup - Always use the Disconnect node at the end of your flow to close connections
- Error Handling - Wrap database operations in Try-Catch blocks to handle connection failures gracefully
- SSL Configuration - For production, use SSL connections; for development, you may disable SSL in parameters
Common Errors and Solutions
Cannot Connect to MySQL Server
Error: ErrConnection: Cannot connect to MySQL server
Solutions:
- Verify the MySQL server is running
- Check server hostname/IP address is correct
- Ensure the port number is correct (default: 3306)
- Verify firewall rules allow connections on MySQL port
- Check username and password are correct
- Test connection from MySQL client tools first
Missing Credentials Error
Error: ErrCredentials: No credentials provided
Solutions:
- Select a Database credential from the vault in the Credentials field
- Ensure the credential contains required fields (server, username)
Authentication Plugin Error
Error: Authentication plugin issues or public key retrieval errors
Solutions:
- Add to Parameters:
AllowPublicKeyRetrieval=true - Or update MySQL user to use
mysql_native_passwordauthentication
Connection String Parameters
Common parameters you can use in the Parameters field:
SslMode=none- Disable SSL encryptionSslMode=Required- Require SSL encryptionAllowPublicKeyRetrieval=true- Allow public key retrieval for authenticationConnectionTimeout=30- Set connection timeout in secondsDefaultCommandTimeout=300- Set command timeout in secondsCharSet=utf8mb4- Set character setAllowUserVariables=true- Allow user variables in SQLUseAffectedRows=false- Use matched rows instead of affected rows
See Also
- Disconnect - Close database connections
- Query - Execute SELECT queries
- Non Query - Execute INSERT, UPDATE, DELETE
- Insert - Bulk insert table data