Does digital ocean prohibit tcp connections to localhost on a mysql server?
I am trying to connect to a database with a c++ program. I am using the mysqlcppconnector with the connection strings tcp://localhost:3306 and tcp://127.0.0.1:3306. The program works on my local machine, but when I try to run it on my digital ocean Ubuntu server after ssh'ing in, it complains:
terminate called after throwing an instance of 'sql::SQLException' what(): Unknown MySQL server host 'tcp' (2)
I have tried many ports, including the default of 3306. I can also connect to the database outside of c++, manually on the command line, by typing in
mysql -u root -p. After that, I can type
show variables; and indeed I see skip-networking set to “OFF”, which is what it should be. Finally, MySQL appears to be listening on the network:
netstat -a | grep mysql tcp 0 0 localhost:mysql 0.0.0.0:* LISTEN unix 2 [ ACC ] STREAM LISTENING 20025 /var/run/mysqld/mysqld.sock
Is there some configuration that I forgot to change? What does the “(2)” mean?