I’m trying to connect to my mySQL server with the C interface via a SSH tunnel.
What I currently do is open the SSH tunnel :
ssh user@IP -L 10293:127.0.0.1:3306
And then in code :
MYSQL *conn = mysql_init(NULL);
mysql_real_connect(conn, "localhost", "username", "password", "production", 10293, NULL, 0);
unsigned int error = mysql_errno(conn);
I get the error 2002 just after having connecting. Error 2002 is “Can’t connect to local MySQL server through socket”. However, why is it trying to connect via socket when I didn’t specify any socket in the connection?
What else could possibly go wrong?
Username, password and table name have been checked multiple times of course.
I needed to specify “127.0.0.1” instead of “localhost” as the address since I was binding the IP itself, and not the actually localhost.