Weintek To MySQL Database Server
Weintek To MySQL Database Server
Note:
1.If you download MySQL Server 8.0 or use a later version for installation,
please select “Use Legacy Authentication Method (Retain MYSQL 5.x
Compatibility)” on the Authentication Method menu during the installation.
2. The Weintek HMI requires a user credential to log in to your MySQL server. To create
a user account within MySQL server using MySQL Workbench, please follow the
steps below:
Page 1 of 26
Weintek HMI to MySQL Database Server
3. The Weintek HMI requires a database in your MySQL server to store data or query
the database. To create a database using MySQL Workbench, please follow the steps
below:
Contents:
Appendix A………………………………………………………………………………………………………………………...22
Appendix B………………………………………………………………………………………………………………….……..24
Appendix C…………………………………………………………………………………………………………………………25
Page 2 of 26
Weintek HMI to MySQL Database Server
This object allows a Weintek HMI to connect to your MySQL database server and access
the specified database. You must establish a MySQL connection before following the
steps in Chapter 2, Chapter 3, or Chapter 4.
1. Launch Easybuilder pro and open your project. Go to the [Data/History] tab »
[Database Server].
On the [General] tab, enter the IP address, port number, and a user account for your
MySQL server. Database name depends on what database you want to use for SQL Sync
or SQL Query.
3.On the [TLS/SSL] tab, you can enable TLS/SSL encryption and server verification when
using MySQL as your server. This feature is available in Easybuilder Pro v6.04.01.250 or
greater.
Page 3 of 26
Weintek HMI to MySQL Database Server
4.On the [Status/Control] tab, define the Status address to display the connection status
on the HMI screen. You can define a Control address if enabled to change the following
server parameters on the HMI screen during runtime.
Page 4 of 26
Weintek HMI to MySQL Database Server
5.Create the following objects on the editing area. These objects are used to monitor
and control the MySQL server connection.
Once the Weintek HMI succeeds in connecting to the MySQL server, the “Connected”
message will be displayed in the Status address.
Value Description
0 Not attempting to connect to the server
1 Failed to connect to the server
2 Connected to the server
Value Description
0 No error
1 Unknown error
2 Failed to connect to database
3 Database blocks the unauthorized connection
4 Incorrect database name
5 Invalid domain name
Page 5 of 26
Weintek HMI to MySQL Database Server
The Sync to database option will be available in the Data Sampling and the Event Log
after you finish the steps in Chapter 1.
Data Sampling
Follow these steps after you have created your data logs in Data Sampling.
2. Under History file select [Enable] and then select the [Sync to database] option. Once
configured, select a database server to store your historical data.
Note: SQL sync. does NOT support “Customized file handling.” You must select “All
records in one file.”
3.You can enable a Control address to trigger the following actions by issuing the
corresponding commands. The HMI will perform auto synchronization at the specified
time interval if Auto sync. Periodically is enabled.
Command Description
Number
1 This command will clear all logged records in the HMI flash memory.
2 This command will synchronize the historical data to the MySQL server.
3 This command will synchronize the historical data to the MySQL server
and then clear all logged records in the HMI flash memory.
For more information about the Control address, please refer to the Easybuilder Pro
user manual.
Page 6 of 26
Weintek HMI to MySQL Database Server
Page 7 of 26
Weintek HMI to MySQL Database Server
Testing – Click the [Sync] button, which is used to issue command #2 via a Set Word
object. If the sync succeeds, the following three tables will be generated in your
database.
Page 8 of 26
Weintek HMI to MySQL Database Server
Note: The HMI will transfer the original data logs to the MySQL server. Please use
SELECT statement to get a table that contains specific organized data.
Page 9 of 26
Weintek HMI to MySQL Database Server
Event Log
Configuring the SQL Sync for the Event Log is similar to the Data Sampling section.
Follow these steps after you have created your event logs in Event Log(Alarm).
2. Under History file select [Enable] and then select the [Sync to database] option. Once
configured, select a database server to store your historical data.
3.You can enable a Control address to trigger the following actions by issuing the
corresponding commands. The HMI will perform auto synchronization at the specified
time interval if Auto sync. Periodically is enabled.
Command Description
Number
1 This command will clear all logged records in the HMI flash memory.
2 This command will synchronize the historical data to the MySQL server.
3 This command will synchronize the historical data to the MySQL server
and then clear all logged records in the HMI flash memory.
For more information about the Control address, please refer to the Easybuilder Pro
user manual.
Page 10 of 26
Weintek HMI to MySQL Database Server
Page 11 of 26
Weintek HMI to MySQL Database Server
Note: The HMI will transfer the original event logs to the MySQL server. Please use
SELECT statement to get a table that contains specific organized data.
You can look up the event messages in the event log table.
Page 12 of 26
Weintek HMI to MySQL Database Server
Before you configure a SQL Query object to query your MySQL server, you will need to
finish the steps in Chapter 1.
A database may contain several tables as shown below. In this example, the HMI will
pull out of data from PRODUCTION_DATA table.
Click on the [New] button to add the columns of the table or click on [Import
from server] to import the column’s information from the MySQL server.
Page 13 of 26
Weintek HMI to MySQL Database Server
Based on the data format in your MySQL server, select the correct data type for
each column under the [Address format] column. If the column is string data,
enter the number of words under the [Word count] column.
4. On the [Command] tab, define a register for the Control Address. The following
parameters will populate the sequential registers. During runtime, you can query
the MySQL server by entering a Command ID into the Command ID register,
which is LW-100 in this case.
Create (Issuing Command number 1), Read (Issuing Command number 2)
Update (Issuing Command number 3), and Delete (Issuing Command number 4)
Page 14 of 26
Weintek HMI to MySQL Database Server
5. You can create another SQL query object to query other tables if needed.
6. Create four Set Word objects on the editing area to issue the Commands during
runtime.
7. Go to the [Data/History] tab and create a [SQL Query Result Viewer] object on
the editing area. Once the HMI succeeds in performing a Select command, the
result will be displayed in the SQL Query Result Viewer object.
Filter enabled: Allows you to enter keywords into this object during runtime to
search for a specific record.
Page 15 of 26
Weintek HMI to MySQL Database Server
Before you configure a SQL Query object to query your MySQL server, you will need to finish the
steps in Chapter 1. In advanced mode, you can write your own SQL statement to perform a
specific query.
1. Go to the [Data/History] tab » [SQL Query]. Then click on the [New] button to
create a new query.
2. The SQL Query which is set to Basic mode, like the one you created in Chapter 3,
can switch to advanced mode. Once you check the [Advanced mode] checkbox,
it cannot be undone for that SQL Query.
3. The setting dialog will be displayed as shown after being switched to advanced
mode. On the [General] tab, select a MySQL server.
Page 16 of 26
Weintek HMI to MySQL Database Server
4. On the [Command] tab, there are four SQL commands converted to the
following format.
No. of arguments: the number of data columns you want to be dynamic.
No. of outputs: the number of data columns used for the result.
Click the [New] button to create a command or click the [Settings] button to
modify the selected command.
Page 17 of 26
Weintek HMI to MySQL Database Server
On [Argument] tab, specify a register for the argument. The HMI will refer to the
registers specified on this tab corresponding to the argument number enclosed
in ${ }
Page 18 of 26
Weintek HMI to MySQL Database Server
On [Result] tab, specify registers for the result. The result will populate the
specified registers.
Once completing the dynamic configuration, the value of No. of arguments will be 1.
6. You can create another SQL query to query other tables if needed.
Page 19 of 26
Weintek HMI to MySQL Database Server
7. Create four Set Word objects on the editing area to issue the commands during
runtime.
8. Go to the [Data/History] tab and create a [SQL Query Result Viewer] object on
the editing area. Once the HMI succeeds in performing a Select command, the
result will be displayed on the SQL Query Result Viewer object.
Filter enabled: Allows you to enter keywords into this object during runtime to
search for a specific record.
Page 20 of 26
Weintek HMI to MySQL Database Server
Page 21 of 26
Weintek HMI to MySQL Database Server
Appendix A
The SQL Sync and SQL Query features provide status registers to simplify
troubleshooting during runtime.
SQL SYNC
Value Description
0 Disconnected from the database server
1 Connecting with the database server
2 Connected with the database server
3 Storing records into the archive. When this is done, the value returns to 2.
Page 22 of 26
Weintek HMI to MySQL Database Server
SQL Query
Status
Value Description
0 Normal
1 Query result exceeds 1000 records (rows). Use LIMIT clause to reduce number
of rows.
Error
Page 23 of 26
Weintek HMI to MySQL Database Server
Appendix B
If data type conversion cannot run properly, error code 5 will show in the specified error
register. For example, when converting MySQL’s INT into EB Pro’s 16-bit unsigned, error
code 5 will show if the value exceeds the limit of 16-bit unsigned data.
Page 24 of 26
Weintek HMI to MySQL Database Server
Appendix C
Your PC which runs the MySQL server needs to allow traffic going to the defined TCP
port to pass through. The Open Firewall port option is available during the MySQL
installation.
You can manually configure the firewall port by the following these steps.
Page 25 of 26
Weintek HMI to MySQL Database Server
Other company names, product names, or trademarks in this document are the trademarks or
registered trademarks of their respective companies.
Page 26 of 26