0

I have simple vibe-D program which is trying to connect to SQL:

import std.stdio;
import mysql;
import vibe.d;
void main()
{
  MySQLPool db_pool = new MySQLPool("localhost","root","","dbname",3306);
  Connection db = db_pool.lockConnection();
  // same thing happens with:
  // string connectionStr = "host=localhost;port=3306;user=root;db=dbname";
  // db = new Connection(connectionStr);
}

(I deleted everything else for simplification)

Dependencies:

"dependencies": {
  "mysql-native": "~>3.2.0",
  "vibe-d": "~>0.9.4"
}

And it fails to connect with:

object.Exception@../../../.dub/packages/vibe-core-1.22.4/vibe-core/source/vibe/core/net.d(256): Failed to connect to [0:0:0:0:0:0:0:1]:3306: refused

When I try it without vibe-d in the dub project (using phobos sockets) it connects with no problem. What am I doing wrong?

GTO
  • 127
  • 11
  • 1
    that's an ipv6 address.... is your mysql listening on that interface? might help trying `127.0.0.1` instead of `localhost` and seeing what happens. – Adam D. Ruppe Jun 30 '22 at 16:17
  • wow, that was it! Thank you so much. Feel free to create an answer if you want – GTO Jul 01 '22 at 06:58

1 Answers1

3

that's an ipv6 address.... is your mysql listening on that interface? might help trying 127.0.0.1 instead of localhost and seeing what happens.

can also consider reconfiguring mysql to listen on all interfaces too, including the ipv6

Adam D. Ruppe
  • 25,382
  • 4
  • 41
  • 60