Recent

Author Topic: Error to connect to database  (Read 2690 times)

Whillis

  • New Member
  • *
  • Posts: 10
Error to connect to database
« on: December 05, 2018, 02:20:40 am »
 Im trying to connect a database i made in Mysql workbench to lazarus with zeoslib, but whenever i create a
connection = true it gives me this error message:

SQL Error: Client does not support authentication protocol
requested by server; consider upgrading MySQL client

im a total beginner with this stuff and really dont know what to do now.
Error - 404

mangakissa

  • Hero Member
  • *****
  • Posts: 1090
Re: Error to connect to database
« Reply #1 on: December 05, 2018, 08:13:12 am »
Use the right client library of your mysql database.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Whillis

  • New Member
  • *
  • Posts: 10
Re: Error to connect to database
« Reply #2 on: December 05, 2018, 10:57:01 am »
Is it something i got to download or a property i have to change somewhere?
Error - 404

Zvoni

  • Sr. Member
  • ****
  • Posts: 392
Re: Error to connect to database
« Reply #3 on: December 05, 2018, 11:47:58 am »
Which MySQL-Server-Version?
IIRC they changed the default-authentication from 5.7 to 8
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

Whillis

  • New Member
  • *
  • Posts: 10
Re: Error to connect to database
« Reply #4 on: December 05, 2018, 11:53:14 am »
here it says MySQL server  Version:8.0.13 x64
just like workbench, but i dont know if the libraries are something apart
from that.
Error - 404

Zvoni

  • Sr. Member
  • ****
  • Posts: 392
Re: Error to connect to database
« Reply #5 on: December 05, 2018, 12:08:16 pm »
here it says MySQL server  Version:8.0.13 x64
just like workbench, but i dont know if the libraries are something apart
from that.

And that's probably the Problem......
AFAIK, the TSQLConnection has not been updated to MySQL8
Anyone want to correct me?

Looks like it:
https://mysqlserverteam.com/upgrading-to-mysql-8-0-default-authentication-plugin-considerations/
« Last Edit: December 05, 2018, 12:12:43 pm by Zvoni »
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

Whillis

  • New Member
  • *
  • Posts: 10
Re: Error to connect to database
« Reply #6 on: December 05, 2018, 12:27:56 pm »
oh so i need an older version of mySQL to work ou with database connection?
if so which one could be the most updated to be able to do that something around version 5.7?
Error - 404

rvk

  • Hero Member
  • *****
  • Posts: 4278
Re: Error to connect to database
« Reply #7 on: December 05, 2018, 12:32:06 pm »
AFAIK, the TSQLConnection has not been updated to MySQL8
Anyone want to correct me?
OP uses zeos so probably uses TZConnection.

I haven't tested it myself but with the latest ZeosLib it should work.
https://forum.lazarus.freepascal.org/index.php?topic=41855.0

@Whillis, what version of ZeosLib do you have?

Whillis

  • New Member
  • *
  • Posts: 10
Re: Error to connect to database
« Reply #8 on: December 05, 2018, 12:40:00 pm »
 ZeosLib 7.2.4
Error - 404

rvk

  • Hero Member
  • *****
  • Posts: 4278
Re: Error to connect to database
« Reply #9 on: December 05, 2018, 01:05:01 pm »
ZeosLib 7.2.4
Which is the latest stable version. But it is from 2018-03-25. MySQL 8.0 standard became available on 2018-04-19 so it could be ZeosLib 7.2.4 doesn't have the latest changes in it. You might have better luck with a newer version.

You could also try the following in Workbench:

Code: [Select]
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
flush privileges;
(where password is your password and root your user)
« Last Edit: December 05, 2018, 01:07:00 pm by rvk »

Zvoni

  • Sr. Member
  • ****
  • Posts: 392
Re: Error to connect to database
« Reply #10 on: December 05, 2018, 03:01:53 pm »
Quick question: Does anybody know if MySQL8-Support will be included in FPC3.2.X or higher?
I've looked at the source-code of mysqlconn.inc
Code: [Select]
const
  Mysql_Option_Names : array[mysql_option] of string = ('MYSQL_OPT_CONNECT_TIMEOUT','MYSQL_OPT_COMPRESS',
     'MYSQL_OPT_NAMED_PIPE','MYSQL_INIT_COMMAND',
     'MYSQL_READ_DEFAULT_FILE','MYSQL_READ_DEFAULT_GROUP',
     'MYSQL_SET_CHARSET_DIR','MYSQL_SET_CHARSET_NAME',
     'MYSQL_OPT_LOCAL_INFILE','MYSQL_OPT_PROTOCOL',
     'MYSQL_SHARED_MEMORY_BASE_NAME','MYSQL_OPT_READ_TIMEOUT',
     'MYSQL_OPT_WRITE_TIMEOUT','MYSQL_OPT_USE_RESULT',
     'MYSQL_OPT_USE_REMOTE_CONNECTION','MYSQL_OPT_USE_EMBEDDED_CONNECTION',
     'MYSQL_OPT_GUESS_CONNECTION','MYSQL_SET_CLIENT_IP',
     'MYSQL_SECURE_AUTH'
{$IFDEF MYSQL50_UP}
     ,'MYSQL_REPORT_DATA_TRUNCATION', 'MYSQL_OPT_RECONNECT'
{$IFDEF mysql51_UP}
     ,'MYSQL_OPT_SSL_VERIFY_SERVER_CERT'
{$IFDEF mysql55_UP}
     ,'MYSQL_PLUGIN_DIR', 'MYSQL_DEFAULT_AUTH'
{$IFDEF MYSQL56_UP}
     ,'MYSQL_OPT_BIND'
     ,'MYSQL_OPT_SSL_KEY', 'MYSQL_OPT_SSL_CERT', 'MYSQL_OPT_SSL_CA', 'MYSQL_OPT_SSL_CAPATH', 'MYSQL_OPT_SSL_CIPHER', 'MYSQL_OPT_SSL_CRL', 'MYSQL_OPT_SSL_CRLPATH'
     ,'MYSQL_OPT_CONNECT_ATTR_RESET', 'MYSQL_OPT_CONNECT_ATTR_ADD', 'MYSQL_OPT_CONNECT_ATTR_DELETE'
     ,'MYSQL_SERVER_PUBLIC_KEY'
     ,'MYSQL_ENABLE_CLEARTEXT_PLUGIN'
     ,'MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS'
{$IFDEF MYSQL57_UP}
     ,'MYSQL_OPT_SSL_ENFORCE'
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
     );
Is it going to be updated according to https://dev.mysql.com/doc/refman/8.0/en/mysql-options.html
MYSQL_OPT_GET_SERVER_PUBLIC_KEY is missing right now (didn't check the rest).
And yes: I#m aware that it's not only the Const that has to be changed/updated, probably also the Open-Method and what not
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

young_nandy

  • New Member
  • *
  • Posts: 28
Re: Error to connect to database
« Reply #11 on: December 06, 2018, 12:57:46 am »
this means the zeoslib version does not support mysql. it's better to install the odbc for mysql driver. it's free  :D :D :D :D :D

Whillis

  • New Member
  • *
  • Posts: 10
Re: Error to connect to database
« Reply #12 on: December 06, 2018, 01:59:12 am »
 Ok late reply. But i got to fix it, and was very simple, instead of using mysql 5 as protocol i've put
mariaDB-10 which worked out just right with libmariaDb!

Thank you all!
Error - 404

 

TinyPortal © 2005-2018