pavel-entry - 2020-11-18

Hello,

I am using Codesys V3.5 SP16 and Codesys Control for Raspberry PI version 3.5.16.20
I would like to connect to my mySQL database. When I try to connect from raspberry pi using python, the connection works fine. But if I want to connect to mysql in codesys using the following library:
https://store.codesys.com/mysql-library-sl.html?___store=en#1

I can't connect.

Code is following:
VAR
_sHost:STRING:='192.168.0.1';
_uiPort:UINT:=3306;
_sDatabase:STRING:='database';
_sUsername:STRING:='user';
_sPassword:STRING:='password';
xDoOpen:BOOL;
_xConnectionState:BOOL;
MySQL_ConnString:MySQL.MySQL_ConnectionString;
MySQL_Open:MySQL.MySQL_Open;
_Error_name:MySQL.ERROR;
_State:STRING;
END_VAR

    xDoOpen:=TRUE;
    MySQL_Open(
        sHost:=_sHost,
        uiPort:=_uiPort,
        sDatabase:=_sDatabase,
        sUsername:=_sUsername,
        sPassword:=_sPassword,
        xStart:=xDoOpen,
        MySQL_Connection:=MySQL_ConnString,
        sExeute_State=>_State,
        eError=>_Error_name,
        xConnected=>_xConnectionState
    );

Once started, the _State variable is in the "Connection ok - waiting for HS" state. After a few seconds, it jumps to the "Error" state.

Can you please advise me where the problem might be?
Thank you!