Forum > Databases

mysql_connect() fails with error Can't create TCP/IP socket

(1/1)

Boromir:
Hi,
I try to connect to a MySQL-Server that runs on localhost:3306.
With java and MySQL-connector this works fine.
Now I want to do that with fpc.
I used the tutorial on the wiki
http://wiki.lazarus.freepascal.org/index.php/Lazarus_Database_Tutorial#Lazarus_and_MySQL

This is my function:

//uses MySQL3   just for info


--- Code: ---
function fConnect(const Host, User, Passwd: PChar) : boolean;
var mysql : TMYSQL;
    alloc, sock : PMYSQL;
    res : boolean;
begin
     res := true;
     alloc := mysql_init(@mysql);
     write('Connecting to MySQL... ');
     //sock := mysql_connect(alloc, host, user, Passwd);
     sock := mysql_real_connect(alloc, host, user, Passwd, 0, nil, 0);
     if assigned(sock) THEN
     begin
          Writeln('done');
          Writeln('Connection data:');
          Writeln ('Host info       : ',mysql_get_host_info(sock));
          Writeln ('Server info     : ',mysql_stat(sock));
          Writeln ('Client info     : ',mysql_get_client_info);
     end
     else
     begin
          res := false;
          writeln('failed');
          writeln(stderr, mysql_error(@mysql));
     end;
     
     fConnect := res;
end;

--- End code ---

But I get following error message:
Can't create TCP/IP socket (10106)

Version of MySQL 3.23 (but I'm currently downloading 4.1)

So what am I doing wrong, or is it a bug?


Regards
  Fabian

Boromir:
Solved.
Previously the MySQL-Server-Deamon was mysqld.exe
but it has to be mysqld-nt.exe

That's it.

Connecting to a MySQL-Server on Linux which runs on another Computer works, too.

Bye.

Navigation

[0] Message Index

Go to full version