1

I cannot connect to my database which is hosted on OVH remotely from Flutter's package mysql1 and get the following error:

flutter: SocketException: Failed host lookup: 'saintlouqpweb.mysql.db' (OS Error: nodename nor servname provided, or not known, errno = 8)

I usually access it through phpMyAdmin where I have three fields to fill: the server, the user, and the password. I use exactly the same values than there with mysql1 on Flutter in addition to the database name (the server field of phpMyAdmin being the host field of mysql1).

I have searched for hours a solution but I still find nothing on this forum and on the web. Everything is always brought back to a 'localhost' server or a problem too different from mine.

Here is the piece of code causing the error :

Future<List<dynamic>> getData() async
  {
    try {
      final conn = await MySqlConnection.connect(ConnectionSettings(
        host: 'saintlouqpweb.mysql.db', // the exact server name entered on phpMyAdmin
        user: 'myusername',
        password: '*********',
        db: 'mydatabasename',
      ));

    var results = await conn.query(
      'SELECT * FROM `mytable` WHERE ID=1;'
    );

    return results.toList();
    } catch (e) {
      print('$e');
    }
  }

I would be grateful if someone can help me about that or experienced the same issue previously.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
ventatto
  • 11
  • 4

2 Answers2

0

As suggested by Mark Rotteveel in comment, the host you provided in code sample does not look valid.

You can find you host address in your OVHcloud manager : https://www.ovh.com/manager/web

It is accessible inside Web Cloud->Databases and in the table General Informations

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Brugere
  • 436
  • 4
  • 16
  • Ok thanks for this suggestion, the admin of the database told me it was normal the access was forbidden (for security reasons), but I will show him your answer – ventatto Mar 01 '22 at 17:09
0

Based on the hostname it looks like you have a shared SQL database. According to this OVH community post remote connections are not allowed.

Martti Käärik
  • 3,601
  • 18
  • 28