   [C++] MySQL fails to connect
  My code:#include "MySQL\mysql.h"#pragma comment( lib, "MySQL/libmysql.lib" )int main(void){MYSQL *sql = new MYSQL(), *connection = 0;mysql_init(sql);connection = mysql_real_connect(sql, "localhost", "root", "mypass", "mydb", 0, 0, 0);if (connection == NULL) {printf(mysql_error(sql));printf("\n");system("pause");return 0;}return 0;}It outputs this:Can't connect to MySQL server on 'localhost' (10061)However if I use mysql -uroot -pmypass in command line, it connect successfully.Anyone know what's the problem? ^^[Edited by - Ripiz on July 12, 2010 1:52:57 AM]
  Maybe try NULL or 127.0.0.1 instead of localhost, and check that your firewall is not blocking your program.   ;  NULL didn't work either, but 127.0.0.1 works. Thank you.   