天天看點

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

環境Ubuntu14.04 mysql5.5

這個錯誤是我用mysql_real_connect()函數的時候,傳回的錯誤列印出來的。

可以先看這個篇如果解決就可以了:

http://blog.csdn.net/leisure512/article/details/5139104

如果不行可以把繼續往下試:

mysql_real_connect(connect, “localhost”, g_db_username, g_db_password, g_dbname, 0, NULL, 0);

改為:

mysql_real_connect(connect, “127.0.0.1”, g_db_username, g_db_password, g_dbname, 0, NULL, 0);

參考:

1.http://blog.csdn.net/leisure512/article/details/5139104

2.https://help.memsql.com/hc/en-us/articles/115001215603-ERROR-2002-HY000-Can-t-connect-to-local-MySQL-server-through-socket-var-run-mysqld-mysqld-sock-