记在这里做个备忘。
使用php或者mysql++ connect数据库时,经常会报 "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)"
采用下面方式可以解决
在数据库的user表中新增一个用户,比如
| Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv
10.1.164.166 | best_image | | Y | Y | Y | Y | Y | Y
后面的pri全是N。
然后重启mysql, connect时就没有问题了
mysqlpp::Connection conn(false);
bool suc = conn.connect("best_image_dr_db", "10.1.164.166", "best_image", "");
//or bool suc = conn.connect("best_image_dr_db", "10.1.164.166:3306", "best_image", "");
bool suc = conn.connect("best_image_dr_db", "10.1.164.166", "best_image", "");
//or bool suc = conn.connect("best_image_dr_db", "10.1.164.166:3306", "best_image", "");