- 5 Minutes to read
- 5 Minutes to read
MySQL is an open-source relational database management system. It is widely used for storing, managing, and retrieving structured data, making it a popular choice for web applications, content management systems, and various other software solutions.
Authorize Connection to MySQL
Please keep in mind that this guide provides general instructions, and your individual setup might need a different approach or some extra steps. Always take your organization's security guidelines into account when you're making these changes. Additionally, it's a good idea to seek assistance from a database administrator or an IT professional to make sure everything is set up correctly.
Create a MySQL User and Set Permissions
Log into MySQL Shell.
Run a command to create a new user. The command below presumes using root user for user creation, however, you can replace it with any user that has role for creating the users and granting permissions.
mysql -u root -p
CREATE USER 'dataddo'@'%' IDENTIFIED BY '***';
Grant CREATE, SELECT, UPDATE, INSERT, DELETE permissions for your database (please replace database_name with the correct value):
GRANT CREATE ON database_name.* TO 'dataddo'@'%'; GRANT INSERT, UPDATE, DELETE ON database_name.* TO 'dataddo'@'%'; FLUSH PRIVILEGES;
Allow Network Connection
For this destination, whitelisting IP addresses is not available in the database system. Instead, you can configure the network access at the firewall level. Here are the general steps:
- Identify the firewall that's protecting your service. This could be a Windows or Linux firewall running on the server itself, or it could be a network firewall.
- Open the firewall's configuration settings. This process will vary depending on the type of your firewall.
- Look for the setting that allows you to define inbound rules or policies.
- Create a new rule or policy that allows inbound traffic on the port that the service is using (the default is 3306) from the Dataddo IP addresses.
- Save your changes and test the connection from Dataddo to make sure everything is working as intended.
- In the Authorizers tab, click on Authorize New Service and select Universal MySQL.
- In the Universal MySQL configuration page, click on Add new account.
- You will be asked to fill the following fields
- Server IP or Hostname: Public IP or hostname of your MySQL Server.
- Database: Name of the database you will use for writing or reading the data.
- Username: Username of your MySQL user.
- Password: Password to your MySQL user.
- Port: Port to connect to MySQL. The default value is 3306.
- TLS/SSL Settings: Keep the value on PREFERRED, this will ensure using the SSL connection when available. If you are using a self-signed certificate, please use SKIP VERIFY.
- [Optional] Configure the connection via SSH tunnel. To do so, please follow these steps.
- Click on Save.
Create a New MySQL Destination
- On the Destinations page, click on the Create Destination button and select the destination from the list.
- Select your account from the drop-down menu.
- Name your destination and click on Save to create your destination.
Click on Add new Account in drop-down menu during authorizer selection and follow the on-screen prompts. You can also go to the Authorizers tab and click on Add New Service.
Create a Flow to MySQL
- Navigate to Flows and click on Create Flow.
- Click on Connect Your Data to add your sources.
- Click on Connect Your Data Destination to add the destination.
- Choose the write mode and fill in the other required information.
- Check the Data Preview to see if your configuration is correct.
- Name your flow, and click on Create Flow to finish the setup.
Table Naming Convention
When naming your table, please make sure the table name contains only:
- Dollar signs
Incorrect String Value Error
Error 1366 (22007): Incorrect string value: '***' for column *** at row ***
This issue may be caused by incorrect encoding in the target table or column. To solve the issue, please follow these steps:
- Ensure your table and column use the utf8mb4 encoding to handle a wider range of characters.
- Run the following query in your MySQL instance to fix the issue. Remember to replace your_table_name with the actual name of your table.
ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Data Too Long Error
Error 1406 (22001): Data too long for column '***' at row ***
This issue may is caused by attempting to insert data that's too lengthy for the specified column's defined data type or length. To solve the issue, please follow these steps:
- Ensure the data you're inserting matches the column's allowed length or data type.
- Run the following query in your MySQL instance to fix the issue. Replace your_table_name with your table's name, your_column_name with the column in question, DATA_TYPE with the desired type (e.g., VARCHAR), and SIZE with the new size limit.
ALTER TABLE your_table_name MODIFY your_column_name DATA_TYPE(SIZE);
Cannot Change Write Mode to Upsert in Existing Flow
This issue specifically occurs when you attempt to change the write mode to upsert for an existing flow to MySQL. Dataddo creates indexes to ensure smooth system operations, and to maintain the integrity of these operations, changes to the write mode in existing flows to MySQL are restricted. However, the following workarounds are available:
- If you can either lose the data in the existing table without consequences or recover it through backfilling, we recommend deleting the table and the existing flow. Then, re-create the flow using upsert to ensure that the table and indexes are correctly established.
- If preserving the existing data is crucial, consider these steps:
- Delete the existing flow.
- Edit the destination table to add a unique index on the columns you wish to include in the composite key. For example, you could use the SQL query like in the example below.
- Re-create the flow, selecting upsert write mode and a composite key that incorporates the column on which you created the unique index.
ALTER TABLE table_name ADD UNIQUE INDEX unique_index_name (column1, column2);