I have tried everything I could find on this forum and the askubuntu forums relating to the issue. None of which have succeeded.
I have the following code. It compiles fine, but when I run it, i get the following error.
#include <stdio.h>
#include <mysql/mysql.h>
int main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
const char *server = "mydomain";
const char *user = "root";
const char *password = "****************";
const char *database = "tester";
const int port = 3307;
conn = mysql_init(NULL);
if (!mysql_real_connect(conn, server, user, password, database, port, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
return(1);
}
if (mysql_query(conn, "SELECT * FROM test;")) {
fprintf(stderr, "%s\n", mysql_error(conn));
return(1);
}
res = mysql_use_result(conn);
while((row = mysql_fetch_row(res)) != NULL) {
printf("%s %s\n", row[1], row[2]);
mysql_free_result(res);
mysql_close(conn);
return(0);
}
}
Can't connect to MySQL server on 'mydomain' (111)
I have tried everything I could find on the internet to make it work. Including commenting out bind-address = 127.0.0.1 in the my.cnf and also tried changing it to bind-address - 0.0.0.0 but does not work. The mysql server is a remote server and root has all privileges both locally and remotely. I have mysql-client on my development machine and am able to connect fine to mysql via the terminal on the dev machine with: mysql -u root -p which is apparent by the picture
So my question is, does anyone have any clue as to why it is not connecting. Obviously it's not a firewall issue or I would not be able to connect from a terminal.
I have even tried compiling and running on the same machine as mysql is running and and still get the same error. I'm at my wits end just about.