[Pdns-users] Unable to specify mysql port in newer versions
Chris Anderton
chris at namerama.com
Fri Jan 30 13:06:28 UTC 2004
Hello
I'm not really a guru, so there may be problems with this patch - please
point them out if there is! I use this and it works fine for me - i run
mysql on a non-standard port so needed this feature. The code was lifted
from an earlier version of powerdns...
--- modules/gmysqlbackend/gmysqlbackend.cc 2003-01-14
15:23:45.000000000 +0000
+++ modules/gmysqlbackend/gmysqlbackend.cc.port 2003-11-08
07:24:38.000000000 +0000
@@ -23,6 +23,7 @@
try {
setDB(new SMySQL(getArg("dbname"),
getArg("host"),
+ getArg("port"),
getArg("socket"),
getArg("user"),
getArg("password")));
@@ -47,6 +48,7 @@
declare(suffix,"user","Pdns backend user to connect as","powerdns");
declare(suffix,"host","Pdns backend host to connect to","");
declare(suffix,"socket","Pdns backend socket to connect to","");
+ declare(suffix,"port","MySQL port to connect to","");
declare(suffix,"password","Pdns backend password to connect with","");
declare(suffix,"basic-query","Basic query","select
content,ttl,prio,type,domain_id,name from records where type='%s' and
name='%s'");
--- modules/gmysqlbackend/smysql.cc 2003-10-11 20:57:19.000000000 +0100
+++ modules/gmysqlbackend/smysql.cc.port 2003-11-08
07:26:49.000000000 +0000
@@ -11,14 +11,15 @@
bool SMySQL::s_dolog;
-SMySQL::SMySQL(const string &database, const string &host, const string
&msocket, const string &user,
+SMySQL::SMySQL(const string &database, const string &host, const string
&port, const string &msocket, const string &user,
const string &password)
{
mysql_init(&d_db);
if (!mysql_real_connect(&d_db, host.empty() ? 0 : host.c_str(),
user.empty() ? 0 : user.c_str(),
password.empty() ? 0 : password.c_str(),
- database.c_str(), 0,
+ database.c_str(),
+ port.empty() ? 0 : atoi(port.c_str()),
msocket.empty() ? 0 : msocket.c_str(),
0)) {
throw sPerrorException("Unable to connect to database");
--- modules/gmysqlbackend/smysql.hh 2003-10-11 20:57:19.000000000 +0100
+++ modules/gmysqlbackend/smysql.hh.port 2003-11-08
07:27:33.000000000 +0000
@@ -10,7 +10,7 @@
class SMySQL : public SSql
{
public:
- SMySQL(const string &database, const string &host="",
+ SMySQL(const string &database, const string &host="", const string
&port="",
const string &msocket="",const string &user="",
const string &password="");
More information about the Pdns-users
mailing list