Bug #109188 mysql_real_connect() giving error on trying to connect Mysql 8.0.28 and above
Submitted: 24 Nov 2022 4:09 Modified: 25 Nov 2022 4:39
Reporter: Rajib Saha Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.28 OS:Any
Assigned to: CPU Architecture:Any

[24 Nov 2022 4:09] Rajib Saha
Description:
Hi,

From our product, we use Mysql as an optional database.

It was working fine till Mysql 8.0.27.

But, from Mysql 8.0.28, we are getting error as “SSL connection error” and error number as 2026.

We are calling MySQL Connector APIs as below.
=========================================
m_pMySQL = mysql_init( m_pMySQL );
mysql_real_connect( m_pMySQL, workingHost, user, password, server, port, NULL, CLIENT_MULTI_STATEMENTS );
=========================================

Error we are getting from the API call mysql_real_connect().

What different, we need to do for Mysql 8.0.28 in this context for successful connection?
Is it a Bug from MySQL 8.0.28 onwards? Because, backward compatibility should be there on any release.

Regards
Rajib

How to repeat:

Below APIs call for version 8.0.27 & 8.0.28:
================
m_pMySQL = mysql_init( m_pMySQL );
mysql_real_connect( m_pMySQL, workingHost, user, password, server, port, NULL, CLIENT_MULTI_STATEMENTS );
================

We can see the error in 8.0.28. But, not in 8.0.27.
[24 Nov 2022 13:13] MySQL Verification Team
Hi Mr. Saha,

Thank you for your bug report.

However, we do not have problems in connecting that way ........

Our code is very similar and it goes like this:

----------------------------------------------

if (!(mysql_local = mysql_client_init(nullptr))) {
    fprintf(stdout, "\n mysql_client_init() failed");
    exit(1);
  }

  /* Create connection that supports multi statements */
  if (!(mysql_real_connect(mysql_local, opt_host, opt_user, opt_password,
                           current_db, opt_port, opt_unix_socket,
                           CLIENT_MULTI_STATEMENTS))) {
    fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local));
    exit(1);
  }

----------------------------------------------

Make sure that you are linking your code with 8.0.28 client library ...... 

We can't repeat your problem .......

Also, we do not see why have you chosen "Server" as a category, when this is evidently C API.

If you provide us with a repeatable test case, that will fail on 8.0.31, we shall re-open this bug report.
[25 Nov 2022 4:39] Rajib Saha
Hi,

Thanks for the validation in your side.

Strange part is in our side:
Till Mysql 8.0.27 same code was working. But, for Mysql 8.0.28, same code is getting the mentioned error.
For the reason, I have raised the issue in server component, instead of client.

We are trying with “MySQL Connector C 6.1 “ client for the connection with MySQL 8.0.31 currently in windows.
Please correct me, if any correction required here for the client?

I can see, in your sample code 7th parameter for mysql_real_connect(), “opt_unix_socket” is set. For my case it is set as NULL.
Currently, I am trying in Windows. Does this parameter matters for the case?

Regards
Rajib
[25 Nov 2022 13:01] MySQL Verification Team
Hi Mr. Saha,

What you report is not a bug.

You simply have to use same version of include files with the same version of libmysqlclient.

Also, this is not a server issue, but issue in C API. 

We do not maintain Connector/C, but only our C API.

Not a bug.