Authentication problem with mysql 8 using qt - mysql

I am developing a qt (5.12.2) application which can connect to a mysql server. Recently i tried to connect to a mysql 8 server. I was unable to connect, and got the following error message:
Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found.
After some digging, i found out that the problem was because of the new encryption implemented in mysql 8.
One workaround to this problem was to set the server to the legacy authentication method.
Is there a solution without switching back to the legacy authentication?

There are 2 possible problems which can cause this problem.
You are using the old way and connect with QMYSQL driver using the
MySQL Connector/C (libmysqlclient.dll) connector which not supports
MySQL 8 and the new authentication method.
The second way is that you are using the QODBC driver with an
older release(<8.0) which not supports the new authentication
method.
You can easily solve this problem by switching or upgrading to the latest QODBC driver. You can download the latest version from the MySQL download page. With this little example and with the right connector it will work.
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Driver={MySQL ODBC 8.0 Unicode Driver};Server=example.com;Database=test;Uid=user;Port=3306;Pwd=password;WSID=.");
if (!db.open()) {
qDebug() << db.lastError().text();
} else {
qDebug("success");
}

Related

Delphi 11.1's FireDAC and MySQL: SSL connection error: unknown error number

Ok, I've spent all day on this, and I am stuck, so I'm going to ask for help.
I previously installed Delphi 11 Enterprise in a virtual machine, and also installed MySQL 8.0.27 (64-bit). After obtaining some 32-bit MySQL dlls I was able to easily connect to my database using the FireDAC MySQL driver and from the Data Explorer in the Delphi IDE.
I have now created a new VM and installed both Delphi 11.1 Enterprise and MySQL 8.0.28. After exporting my database from the previous VM, and importing it into this new MySQL server, I tried to attach to the database using FireDAC. Using the same parameters as in the last VM, and the same dlls copied to C:\Windows\SysWOW64, testing the connection fails and produces the following error:
[FireDAC][Phys][MySQL] SSL connection error: unknown error number
I've compared the parameters for connecting to the two databases between the two VMs, and they are the same. And, the connections in MySQL to the two databases also appear to be the same.
One thing that is odd (and I think I know why) is that in the VM where the connection fails, if I view the Info tab of the FireDAC Connection Editor, it says it is using libmysql.dll in the c:\Windows\System32 folder (there's no such file in that folder). But that is also true from the Connection Editor in the VM where FireDAC successfully connects, so I am assuming that System32 is being mapped to C:\Windows\SysWOW64.
If anyone can affirm that they are successfully connecting to MySQL 8... using Delphi 11.1 and FireDAC, and can offer a suggestion for what I need to fix, I will be grateful.
= = = = = = = = = = = = == = = = = = = = =
Update: I've uninstalled MySQL 8.0.28, and reinstalled it using the Development Computer template. I still cannot connect to MySQL using the FireDAC Connection Editor, but I can connect at runtime so long as I employ an FDPhysMySQLDriverLink component, and set the VendorLib property to either libmariadb.dll or libmysql.dll, the 32-bit versions that are stored in the C:\Windows\SysWOW64 folder (thanks Ian Barker for your sample code!). I'm still working on this, since I really want to connect from the IDE, but at least I've had some success.
I have had the same issue today, as part of a whole batch of problems with mysql not running so I updated it and then hit the error above.
My 64 bit Delphi 10.3 Programs would not connect at all - so I changed the physical driver to libmariadb.dll and that has resolved the issue.
Be sure from where your app is loading the libmysql.dll by calling h:= loadlibray('libmysql.dll') /without path/ and then GetModulePath(h) to see its full path.
Remember that Delphi is 32bit and it needs to use 32bit version of lobmysql.dll while a 64bit compiled program would need the same bitbness.
This was nuts. I installed and uninstalled MySQL (and MySQL Workbench and MySQL Script) probably 10 times. The last install worked. I have no idea why this was necessary.

Pentaho PDI ETL : error connection to mysql version 8

It seems that there are issues with the newest MySQL version, I can connect to MySQL database using MySQL workbench, but when I try to connect via Pentaho PDI,
I get this error.
Unable to load authentication plugin 'caching_sha2_password'.
It seems that many people are having issues with current version of MySQL:
I have found this link below:
Authentication plugin 'caching_sha2_password' cannot be loaded
Just wondering if anyone has encountered this issue with Pentaho PDI, and what are the possible solutions.

Error with the version of the database in liferay 7

I work with Eclipse and I want to use the version 7 of Liferay but when I run my Tomcat server I have an error with MySQL.
Please upgrade to at least MySQL 5.6.4. The portal no longer supports older versions of MySQL
Like this the problem is pretty obvious but my SQL version is already 5.7.19
I have check my driver of MySQL in preference->data management->connectivity->driver definition and my MySQL JDBC Driver is 5.1
I want to know if someone already had this issue and know how to fix it
This is how the version gets validated, and this is how the version string gets constructed. I'd say: Please make extra extra extra sure that you are addressing the mysql server that you intend to address:
You can check your mysql version from the mysql command line client by executing select version();. Get your credentials and database URL from Liferay's portal-ext.properties or your appserver's connection pool configuration, depending on where you configured it.

Unable to connect MySQL on system start in Windows Server 2012 R2

I have a Windows service (using .NET framework 4.5) installed on a Windows 2012 R2 machine. I have MySQL connector 6.9.7 and MySQL 5.6.25
When my service is started I am getting following error.
Authentication to host 'xxx.xx.x.xx' for user 'yyyyy' using method 'mysql_native_password' failed with message: Reading from the stream has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
or sometimes:
Unable to connect to any of the specified MySQL hosts.
If I restart the service in a while all seems to work properly. Any idea what the problem is?
Migrating OP's solution from the question to an answer:
After further investigation we have found that our database version was 5.6.25. We have tried same connectivity with our old db 5.5.16 and we didn't face the same issue, so it looks like issue is the database itself. Our new database is installed on a Linux machine.

Disable MySQL secure_auth client option with ZeosLib

I'm trying to connect to a remote MySQL server and i get this exception error:
*Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)*
I'm tried to disable the "secure_auth" option by adding the string "MYSQL_SECURE_AUTH=false" to the TZConnection properties, but i get the same error.
I'm using ZeosLib 7.0.4 and Delphi 7. The server has MySQL 5.0.95
Problem solved!
The server is MySQL 5.0.95 (secure_auth disabled) and I was using libmysql.dll 5.6.11 (secure_auth enabled by default). Placing the libmysql.dll 5.0 in the app folder solved it.
I don't understand yet why i can't change the "MYSQL_SECURE_AUTH" at TZConnection.properties.