Server connect failed (mysql) lazarus / 16-Databases ---------------------------------------------------------------------- Kips · 2011-05-16 13:19 Hi. I'm trying to connect to a MySql database, but i got the exception EDataBaseError with message "Server connect failed". I am using Lazarus version 0.9.30, FPC 2.4.2 under Windows 7 This is my sourcecode: procedure TForm1.Button1Click(Sender: TObject);   var   S: String;   conn : TMySQL50Connection;   query : TSQLQuery;   transaction : TSQLTransaction; begin   conn := TMySQL50Connection.Create(nil);   query := TSQLQuery.Create(nil);   transaction := TSQLTransaction.Create(nil);   try     try       conn.HostName := 'localhost:3306';       conn.UserName := 'myusername';       conn.Password := 'mypassword';       conn.DatabaseName := 'mydatabasename';       conn.Connected := True;                            //      <--   the exception is raised here!       conn.Transaction := transaction;       query.DataBase := conn;       query.SQL.Text := 'select field1 from table1';       query.Open;       query.Last;       S := IntToStr(query.RecordCount) + #13#10;       query.First;       while not query.EOF do       begin         S := S + query.FieldByName('field1').AsString + #13#10;         query.Next;       end;     finally       //transaction.Free;       //query.Free;       //conn.Free;     end;   except     on E: Exception do       ShowMessage(E.message);   end;   Caption:= S; end;            Hope anyone can help me! ---------------------------------------------------------------------- denver · 2011-05-16 14:10 You must assign the Transaction to the connection before set conn.Connected := true ;  conn.DatabaseName := 'mydatabasename';  conn.Transaction := transaction;                        <---- assign the transaction to the connection first.  conn.Connected := True; ---------------------------------------------------------------------- cpalx · 2011-05-16 14:11 Don't forget to configure your mysql server to accept remote conexions ---------------------------------------------------------------------- Kips · 2011-05-16 14:23 cpalx, can you deepen that? ---------------------------------------------------------------------- eny · 2011-05-16 14:28 Quote from: Kips on May 16, 2011, 04:23:36 pmcpalx, can you deepen that?How did you install and configure MySQL? (I'm assuming MySQL runs on the same PC where your Lazarus program is running.) ---------------------------------------------------------------------- 99Percent · 2011-05-16 14:31 can you connect using a db admin client eg, HeidiSQL? ---------------------------------------------------------------------- cpalx · 2011-05-19 12:29 if u connecting in the same machine u must not have problems. ---------------------------------------------------------------------- gyts · 2011-08-19 12:13 Code: [Select]Can not load default MySQL library ("libmysql.dll" or libmysql.dll"). Check your instalation.What to do?