How to Connect MySQL in UiPath

UiPath

 

For the Video Version, please check Our Youtube Video

 

Step 1: You need to have MySQL server running in one of the server

Step 2: MySQL server needs to be allowed to connect from remote. That is its bind-address needs to be "Remote IP or 0.0.0.0"

It can be changed from "/etc/mysql/mysql.conf.d/mysqld.cnf" on MySQL Server (File location may vary)

Step 2: You need to have remote access to the MySQL server with an User and Privilege to work on the Database Server:

To Create user in MySQL - CREATE USER 'UserName'@'remote_server_ip' IDENTIFIED BY 'password'; - Eg. CREATE USER 'hrb'@'192.168.99.1' IDENTIFIED BY 'password';

To Grant privilege to a user in MySQl - GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'remote_server_ip' WITH GRANT OPTION; - Eg. GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'hrb'@'192.168.99.1' WITH GRANT OPTION;

Step 3: MySQL server port 3306 needs to be allowed in the firewall to connect from outside world or remote server (UiPath Studio machine):

To allow MySQL server Port in firewall - sudo ufw allow from remote_IP_address to any port 3306 - Eg. sudo ufw allow from 192.168.99.1 to any port 3306

Step 4: You need MySQL workbench ODBC driver with 32 bit in the machine, where the UiPath Studio is installed.

Step 5: Open ODBC Data Source (32 Bit) on your Windows Machine where the UiPath Studio and MySQL Workbench ODBC driver is installed.

Step 5: Select the System DNS

Step 6: Click Add from the Right pane in the ODBC Data Source window

Step 7: From the displayed options select "MySQL ODBC 8.0 ANSI Driver" (Version may change anytime) and select finish

Step 8: Please provide the following details:

  • Data Source Name - A Name, which best suits this purpose - Eg. RPA_32
  • Description - Description of this purpose - Eg. RPA_32
  • TCP/IP Server - IP Address of the MySQL server - Eg. 192.168.99.116
  • Port - Port number - generally it will be 3306
  • User -Username of MySQL (Step 2) allowed to connect from this machine (Remote user) - Eg. hrb
  • Password - Password of the above mentioned User
  • Click on "Test" to make sure the connection is Successful.

Note: Please resist from selecting the Database here, unless you want to work only with a single database. Else handle it in the UiPath workflow.

After providing the above information, click on "Ok" and "Ok" on all other screens of ODBC Data Source (32 bit) application window

Step 8: Open UiPath Studio

Step 9: Create a new Process Project or open existing Project

Step 10: Open the workflow, In our scenario, open Main Workflow

Step 11: Click on Manage Packages from the Menu Ribbon

Step 12: Select All Packages from the left pane

Step 13: Search for "Database" in the search bar and select "UiPath.Database.Activities by UiPath" and click install from the right pane. Post completion of Installation, click "Save"

Step 14: Now you can see new activities listed in the Activities pane (Under Available - App Integration - Database). You are free to use any.

Step 15: If you need to Connect to a Database, First Activity always advised to use Connect. Hence drag and drop connect.

Step 16: Select "Configure Connection" of the "Connect" activity.

Step 17: Click "Connection Wizard"

Step 18: Select "Microsoft ODBC Data Source" and click "OK"

Step 19: Select "RPA_32" (Step 8) from dropdown of "Use user or system data source name". Click on "Test Connection" to validate the connection to MySQL Again. and Click "OK" & "OK" in further screens

Step 20: Mark the Output of the "Connect" activity with a variable. Eg. Output "DatabseConnection" as "hrbtestdb"

Step 21: Use "Execute Query" Activity as the next activity and run any of the MySQL databse queries by passing the above created variable as Input "Existing Connection" Input for any other Database activities. Eg. Refer below Screenshots.

Step 22: #Shiko #Hodo. Enjoy Learning & Enjoy Developing with UiPath and MJIT.