CDN-old - Cannot connect to MySQL database from OVH server
... / Cannot connect to MySQL d...
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Frage

Cannot connect to MySQL database from OVH server

Von
TimD2
Erstellungsdatum 2022-03-03 14:22:26 (edited on 2024-09-04 14:24:29) in CDN-old

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> 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.