Dbo::MySQL using default socket file over specified one
Added by Rajeev Gajbhiye almost 11 years ago
I was trying to connect to MariaDB using Dbo:MySQL on which I was getting the error that it was unable to connect through socket '/var/run/mysqld/mysqld.sock'. On going through my.cnf file I noticed that default location is /var/lib/mysql/mysql.sock and hence the above error. Then in the constructor of Dbo::MySQL I specified this socket file particularly. Still it tried to use default socket file and not which I specified. When I looked into the code, I noticed that specified socket file is ignored and default is used. The code is as follows.
if(mysql_real_connect(impl*->mysql, dbhost*.c_str(), dbuser_.c_str(),
dbpasswd*.empty() ? 0 : dbpasswd*.c_str(),
dbname*.c_str(), dbport*,
//dbsocket_.c_str(),
"/var/run/mysqld/mysqld.sock",
CLIENT_FOUND_ROWS) != impl_->mysql){
std::string errtext = mysql_error(impl_->mysql);
mysql_close(impl_->mysql);
throw MySQLException(
std::string("MySQL : Failed to connect to database server: ")
- errtext);
}
}
Here dboscket.c_str() is commented and default location is hardcoded. Am curious to know the reason behind the same.
Regards,
Rajeev.
Replies (1)
RE: Dbo::MySQL using default socket file over specified one - Added by Wim Dumon almost 11 years ago
That is indeed a bug. I reworked this already in a local branch, which I expect to merge soon (with a small API change).
BR,
Wim.