diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c
index 8c6d30b..62fd9e5 100644
--- a/openbsc/src/bsc_hack.c
+++ b/openbsc/src/bsc_hack.c
@@ -45,11 +45,15 @@
 /* MCC and MNC for the Location Area Identifier */
 static struct log_target *stderr_target;
 struct gsm_network *bsc_gsmnet = 0;
-static const char *database_name = "hlr.sqlite3";
+static const char *database_host = "localhost";
+static const char *database_name = "openbsc";
+static const char *database_user = "openbsc";
+static const char *database_pass = "openbsc";
 static const char *config_file = "openbsc.cfg";
 extern const char *openbsc_copyright;
 static int daemonize = 0;
 static int use_mncc_sock = 0;
 
 /* timer to store statistics */
 #define DB_SYNC_INTERVAL	60, 0
@@ -85,7 +89,10 @@ static void print_help()
 	printf("  -D --daemonize Fork the process into a background daemon\n");
 	printf("  -c --config-file filename The config file to use.\n");
 	printf("  -s --disable-color\n");
-	printf("  -l --database db-name The database to use\n");
+	printf("  -t --database-host host The host of the MySQL-database to use (default: %s)\n", database_host);
+	printf("  -l --database-name name The name of the MySQL-database to use (default: %s)\n", database_name);
+	printf("  -u --database-user user The user of the MySQL-database to use (default: %s)\n", database_user);
+	printf("  -w --database-pass pass The password for the MySQL-database to use (default: %s)\n", database_pass);
 	printf("  -a --authorize-everyone. Authorize every new subscriber. Dangerous!.\n");
 	printf("  -p --pcap file  The filename of the pcap file\n");
 	printf("  -T --timestamp Prefix every log line with a timestamp\n");
@@ -93,10 +100,14 @@ static void print_help()
 	printf("  -P --rtp-proxy Enable the RTP Proxy code inside OpenBSC\n");
 	printf("  -e --log-level number. Set a global loglevel.\n");
 	printf("  -m --mncc-sock Disable built-in MNCC handler and offer socket\n");
 }
 
 static void handle_options(int argc, char **argv)
 {
 	while (1) {
 		int option_index = 0, c;
 		static struct option long_options[] = {
@@ -105,7 +116,10 @@ static void handle_options(int argc, char **argv)
 			{"daemonize", 0, 0, 'D'},
 			{"config-file", 1, 0, 'c'},
 			{"disable-color", 0, 0, 's'},
-			{"database", 1, 0, 'l'},
+			{"database-host", 1, 0, 't'},
+			{"database-name", 1, 0, 'l'},
+			{"database-user", 1, 0, 'u'},
+			{"database-pass", 1, 0, 'w'},
 			{"authorize-everyone", 0, 0, 'a'},
 			{"pcap", 1, 0, 'p'},
 			{"timestamp", 0, 0, 'T'},
@@ -113,10 +127,11 @@ static void handle_options(int argc, char **argv)
 			{"rtp-proxy", 0, 0, 'P'},
 			{"log-level", 1, 0, 'e'},
 			{"mncc-sock", 0, 0, 'm'},
 			{0, 0, 0, 0}
 		};
 
-		c = getopt_long(argc, argv, "hd:Dsl:ar:p:TPVc:e:m",
+		c = getopt_long(argc, argv, "hd:Dst:l:u:w:ar:p:TPVc:e:m",
 				long_options, &option_index);
 		if (c == -1)
 			break;
@@ -135,9 +150,18 @@ static void handle_options(int argc, char **argv)
 		case 'D':
 			daemonize = 1;
 			break;
+		case 't':
+			database_host = strdup(optarg);
+			break;
 		case 'l':
 			database_name = strdup(optarg);
 			break;
+		case 'u':
+			database_user = strdup(optarg);
+			break;
+		case 'w':
+			database_pass = strdup(optarg);
+			break;
 		case 'c':
 			config_file = strdup(optarg);
 			break;
@@ -160,6 +184,33 @@ static void handle_options(int argc, char **argv)
 			print_version(1);
 			exit(0);
 			break;
 		default:
 			/* ignore */
 			break;
@@ -269,7 +320,7 @@ int main(int argc, char **argv)
 	/* seed the PRNG */
 	srand(time(NULL));
 
-	if (db_init(database_name)) {
+	if (db_init(database_name, database_host, database_user, database_pass)) {
 		printf("DB: Failed to init database. Please check the option settings.\n");
 		return -1;
 	}
@@ -281,6 +332,8 @@ int main(int argc, char **argv)
 	}
 	printf("DB: Database prepared.\n");
 
 	/* setup the timer */
 	db_sync_timer.cb = db_sync_timer_cb;
 	db_sync_timer.data = NULL;
diff --git a/openbsc/src/db.c b/openbsc/src/db.c
index 95a7d36..d02e6d0 100644
--- a/openbsc/src/db.c
+++ b/openbsc/src/db.c
@@ -42,66 +42,81 @@ static char *db_basename = NULL;
 static char *db_dirname = NULL;
 static dbi_conn conn;
 
+/*************************************************************************
+ * To create the MySQL-database use:                                     *
+ * (in this example, openbsc is the name of the DB, the user and his     *
+ * password. Change them to your preferred values. You can give these    *
+ * parameter to the program using the properly command parameters)       *
+ *                                                                       *
+ * CREATE USER 'openbsc'@'localhost' IDENTIFIED BY 'openbsc';            *
+ * GRANT USAGE ON * . * TO 'openbsc'@'localhost' IDENTIFIED BY 'openbsc' *
+ *       WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0          *
+ *       MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;                 *
+ * CREATE DATABASE IF NOT EXISTS `openbsc` ;                             *
+ * GRANT ALL PRIVILEGES ON `openbsc` . * TO 'openbsc'@'localhost';       *
+ * FLUSH PRIVILEGES;                                                     *
+ *************************************************************************/
+
 static char *create_stmts[] = {
 	"CREATE TABLE IF NOT EXISTS Meta ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
-		"key TEXT UNIQUE NOT NULL, "
-		"value TEXT NOT NULL"
+		"mkey VARCHAR(1000) NOT NULL PRIMARY KEY, "
+		"mvalue TEXT NOT NULL"
 		")",
-	"INSERT OR IGNORE INTO Meta "
-		"(key, value) "
+	"INSERT INTO Meta "
+		"(mkey, mvalue) "
 		"VALUES "
-		"('revision', '2')",
+		"('revision', '2') "
+		"ON DUPLICATE KEY UPDATE mvalue = 2",
 	"CREATE TABLE IF NOT EXISTS Subscriber ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
-		"created TIMESTAMP NOT NULL, "
-		"updated TIMESTAMP NOT NULL, "
-		"imsi NUMERIC UNIQUE NOT NULL, "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
+		"created TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', "
+		"updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "
+		"imsi VARCHAR(20) UNIQUE NOT NULL, "
 		"name TEXT, "
-		"extension TEXT UNIQUE, "
+		"extension VARCHAR(255) UNIQUE, "
 		"authorized INTEGER NOT NULL DEFAULT 0, "
-		"tmsi TEXT UNIQUE, "
+		"tmsi VARCHAR(20) UNIQUE, "
 		"lac INTEGER NOT NULL DEFAULT 0"
 		")",
 	"CREATE TABLE IF NOT EXISTS AuthToken ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
-		"subscriber_id INTEGER UNIQUE NOT NULL, "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
+		"subscriber_id INT(10) UNSIGNED UNIQUE NOT NULL, "
 		"created TIMESTAMP NOT NULL, "
-		"token TEXT UNIQUE NOT NULL"
+		"token VARCHAR(1000) UNIQUE NOT NULL"
 		")",
 	"CREATE TABLE IF NOT EXISTS Equipment ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
-		"created TIMESTAMP NOT NULL, "
-		"updated TIMESTAMP NOT NULL, "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
+		"created TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', "
+		"updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "
 		"name TEXT, "
-		"classmark1 NUMERIC, "
+		"classmark1 INT(10) UNSIGNED, "
 		"classmark2 BLOB, "
 		"classmark3 BLOB, "
-		"imei NUMERIC UNIQUE NOT NULL"
+		"imei VARCHAR(20) UNIQUE NOT NULL"
 		")",
 	"CREATE TABLE IF NOT EXISTS EquipmentWatch ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
-		"created TIMESTAMP NOT NULL, "
-		"updated TIMESTAMP NOT NULL, "
-		"subscriber_id NUMERIC NOT NULL, "
-		"equipment_id NUMERIC NOT NULL, "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
+		"created TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', "
+		"updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "
+		"subscriber_id INT(10) UNSIGNED NOT NULL, "
+		"equipment_id INT(10) UNSIGNED NOT NULL, "
 		"UNIQUE (subscriber_id, equipment_id) "
 		")",
 	"CREATE TABLE IF NOT EXISTS SMS ("
 		/* metadata, not part of sms */
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
 		"created TIMESTAMP NOT NULL, "
-		"sent TIMESTAMP, "
-		"sender_id INTEGER NOT NULL, "
-		"receiver_id INTEGER NOT NULL, "
-		"deliver_attempts INTEGER NOT NULL DEFAULT 0, "
+		"sent TIMESTAMP NULL DEFAULT NULL, "
+		"sender_id INT(10) UNSIGNED NOT NULL, "
+		"receiver_id INT(10) UNSIGNED NOT NULL, "
+		"deliver_attempts INT(10) UNSIGNED NOT NULL DEFAULT 0, "
 		/* data directly copied/derived from SMS */
 		"valid_until TIMESTAMP, "
-		"reply_path_req INTEGER NOT NULL, "
-		"status_rep_req INTEGER NOT NULL, "
-		"protocol_id INTEGER NOT NULL, "
-		"data_coding_scheme INTEGER NOT NULL, "
-		"ud_hdr_ind INTEGER NOT NULL, "
+		"reply_path_req INT(10) UNSIGNED NOT NULL, "
+		"status_rep_req INT(10) UNSIGNED NOT NULL, "
+		"protocol_id INT(10) UNSIGNED NOT NULL, "
+		"data_coding_scheme INT(10) UNSIGNED NOT NULL, "
+		"ud_hdr_ind INT(10) UNSIGNED NOT NULL, "
 		"dest_addr TEXT, "
 		"user_data BLOB, "	/* TP-UD */
 		/* additional data, interpreted from SMS */
@@ -109,42 +124,42 @@ static char *create_stmts[] = {
 		"text TEXT "		/* decoded UD after UDH */
 		")",
 	"CREATE TABLE IF NOT EXISTS VLR ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
-		"created TIMESTAMP NOT NULL, "
-		"updated TIMESTAMP NOT NULL, "
-		"subscriber_id NUMERIC UNIQUE NOT NULL, "
-		"last_bts NUMERIC NOT NULL "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
+		"created TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', "
+		"updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "
+		"subscriber_id INT(10) UNSIGNED UNIQUE NOT NULL, "
+		"last_bts INT(10) UNSIGNED NOT NULL "
 		")",
 	"CREATE TABLE IF NOT EXISTS ApduBlobs ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
 		"created TIMESTAMP NOT NULL, "
-		"apdu_id_flags INTEGER NOT NULL, "
-		"subscriber_id INTEGER NOT NULL, "
+		"apdu_id_flags INT(10) UNSIGNED NOT NULL, "
+		"subscriber_id INT(10) UNSIGNED NOT NULL, "
 		"apdu BLOB "
 		")",
 	"CREATE TABLE IF NOT EXISTS Counters ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
 		"timestamp TIMESTAMP NOT NULL, "
-		"value INTEGER NOT NULL, "
+		"value INT(10) UNSIGNED NOT NULL, "
 		"name TEXT NOT NULL "
 		")",
 	"CREATE TABLE IF NOT EXISTS RateCounters ("
-		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
+		"id INT(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT, "
 		"timestamp TIMESTAMP NOT NULL, "
-		"value INTEGER NOT NULL, "
+		"value INT(10) NOT NULL, "
 		"name TEXT NOT NULL, "
-		"idx INTEGER NOT NULL "
+		"idx INT(10) NOT NULL "
 		")",
 	"CREATE TABLE IF NOT EXISTS AuthKeys ("
-		"subscriber_id INTEGER PRIMARY KEY, "
-		"algorithm_id INTEGER NOT NULL, "
+		"subscriber_id INT(10) UNSIGNED PRIMARY KEY, "
+		"algorithm_id INT(10) UNSIGNED NOT NULL, "
 		"a3a8_ki BLOB "
 		")",
 	"CREATE TABLE IF NOT EXISTS AuthLastTuples ("
-		"subscriber_id INTEGER PRIMARY KEY, "
+		"subscriber_id INT(10) UNSIGNED PRIMARY KEY, "
 		"issued TIMESTAMP NOT NULL, "
-		"use_count INTEGER NOT NULL DEFAULT 0, "
-		"key_seq INTEGER NOT NULL, "
+		"use_count INT(10) UNSIGNED NOT NULL DEFAULT 0, "
+		"key_seq INT(10) UNSIGNED NOT NULL, "
 		"rand BLOB NOT NULL, "
 		"sres BLOB NOT NULL, "
 		"kc BLOB NOT NULL "
@@ -164,7 +179,7 @@ static int check_db_revision(void)
 	const char *rev;
 
 	result = dbi_conn_query(conn,
-				"SELECT value FROM Meta WHERE key='revision'");
+				"SELECT mvalue FROM Meta WHERE mkey='revision'");
 	if (!result)
 		return -EINVAL;
 
@@ -172,7 +187,7 @@ static int check_db_revision(void)
 		dbi_result_free(result);
 		return -EINVAL;
 	}
-	rev = dbi_result_get_string(result, "value");
+	rev = dbi_result_get_string(result, "mvalue");
 	if (!rev || atoi(rev) != 2) {
 		dbi_result_free(result);
 		return -EINVAL;
@@ -182,11 +197,12 @@ static int check_db_revision(void)
 	return 0;
 }
 
-int db_init(const char *name)
+int db_init(const char *name, const char *host, const char *user, const char *passwd)
 {
 	dbi_initialize(NULL);
 
-	conn = dbi_conn_new("sqlite3");
+//	conn = dbi_conn_new("sqlite3");
+	conn = dbi_conn_new("mysql");
 	if (conn == NULL) {
 		LOGP(DDB, LOGL_FATAL, "Failed to create connection.\n");
 		return 1;
@@ -194,19 +210,18 @@ int db_init(const char *name)
 
 	dbi_conn_error_handler( conn, db_error_func, NULL );
 
-	/* MySQL
-	dbi_conn_set_option(conn, "host", "localhost");
-	dbi_conn_set_option(conn, "username", "your_name");
-	dbi_conn_set_option(conn, "password", "your_password");
-	dbi_conn_set_option(conn, "dbname", "your_dbname");
+	/* MySQL */
+	dbi_conn_set_option(conn, "host", host);
+	dbi_conn_set_option(conn, "username", user);
+	dbi_conn_set_option(conn, "password", passwd);
+	dbi_conn_set_option(conn, "dbname", name);
 	dbi_conn_set_option(conn, "encoding", "UTF-8");
-	*/
 
 	/* SqLite 3 */
-	db_basename = strdup(name);
+/*	db_basename = strdup(name);
 	db_dirname = strdup(name);
 	dbi_conn_set_option(conn, "sqlite3_dbdir", dirname(db_dirname));
-	dbi_conn_set_option(conn, "dbname", basename(db_basename));
+	dbi_conn_set_option(conn, "dbname", basename(db_basename)); */
 
 	if (dbi_conn_connect(conn) < 0)
 		goto out_err;
@@ -266,7 +281,7 @@ struct gsm_subscriber *db_create_subscriber(struct gsm_network *net, char *imsi)
 	subscr = db_get_subscriber(net, GSM_SUBSCRIBER_IMSI, imsi);
 	if (subscr) {
 		result = dbi_conn_queryf(conn,
-                         "UPDATE Subscriber set updated = datetime('now') "
+                         "UPDATE Subscriber set updated = now() "
                          "WHERE imsi = %s " , imsi);
 		if (!result)
 			LOGP(DDB, LOGL_ERROR, "failed to update timestamp\n");
@@ -283,7 +298,7 @@ struct gsm_subscriber *db_create_subscriber(struct gsm_network *net, char *imsi)
 		"INSERT INTO Subscriber "
 		"(imsi, created, updated) "
 		"VALUES "
-		"(%s, datetime('now'), datetime('now')) ",
+		"(%s, now(), now()) ",
 		imsi
 	);
 	if (!result)
@@ -327,11 +342,8 @@ static int get_equipment_by_subscr(struct gsm_subscriber *subscr)
 	if (string)
 		strncpy(equip->imei, string, sizeof(equip->imei));
 
-	string = dbi_result_get_string(result, "classmark1");
-	if (string) {
-		cm1 = atoi(string) & 0xff;
-		memcpy(&equip->classmark1, &cm1, sizeof(equip->classmark1));
-	}
+	cm1 = dbi_result_get_uint(result, "classmark1")  & 0xff;
+	memcpy(&equip->classmark1, &cm1, sizeof(equip->classmark1));
 
 	equip->classmark2_len = dbi_result_get_field_length(result, "classmark2");
 	cm2 = dbi_result_get_binary(result, "classmark2");
@@ -529,13 +541,13 @@ int db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
 				"INSERT INTO AuthLastTuples "
 				"(subscriber_id, issued, use_count, "
 				 "key_seq, rand, sres, kc) "
-				"VALUES (%llu, datetime('now'), %u, "
+				"VALUES (%llu, now(), %u, "
 				 "%u, %s, %s, %s ) ",
 				subscr->id, atuple->use_count, atuple->key_seq,
 				rand_str, sres_str, kc_str);
 	} else {
 		char *issued = atuple->key_seq == atuple_old.key_seq ?
-					"issued" : "datetime('now')";
+					"issued" : "now()";
 		result = dbi_conn_queryf(conn,
 				"UPDATE AuthLastTuples "
 				"SET issued=%s, use_count=%u, "
@@ -704,7 +716,7 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber)
 
 	result = dbi_conn_queryf(conn,
 		"UPDATE Subscriber "
-		"SET updated = datetime('now'), "
+		"SET updated = now(), "
 		"name = %s, "
 		"extension = %s, "
 		"authorized = %i, "
@@ -758,7 +770,7 @@ int db_sync_equipment(struct gsm_equipment *equip)
 
 	result = dbi_conn_queryf(conn,
 		"UPDATE Equipment SET "
-			"updated = datetime('now'), "
+			"updated = now(), "
 			"classmark1 = %u, "
 			"classmark2 = %s, "
 			"classmark3 = %s "
@@ -887,7 +899,7 @@ int db_subscriber_alloc_token(struct gsm_subscriber *subscriber, u_int32_t *toke
 		"INSERT INTO AuthToken "
 		"(subscriber_id, created, token) "
 		"VALUES "
-		"(%llu, datetime('now'), \"%08X\") ",
+		"(%llu, now(), \"%08X\") ",
 		subscriber->id, try);
 	if (!result) {
 		LOGP(DDB, LOGL_ERROR, "Failed to create token %08X for "
@@ -910,10 +922,11 @@ int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM_IM
 		sizeof(subscriber->equipment.imei)-1),
 
 	result = dbi_conn_queryf(conn,
-		"INSERT OR IGNORE INTO Equipment "
+		"INSERT INTO Equipment "
 		"(imei, created, updated) "
 		"VALUES "
-		"(%s, datetime('now'), datetime('now')) ",
+		"(%s, now(), now()) "
+		"ON DUPLICATE KEY UPDATE updated = now()",
 		imei);
 	if (!result) {
 		LOGP(DDB, LOGL_ERROR, "Failed to create Equipment by IMEI.\n");
@@ -948,10 +961,11 @@ int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM_IM
 	}
 
 	result = dbi_conn_queryf(conn,
-		"INSERT OR IGNORE INTO EquipmentWatch "
+		"INSERT INTO EquipmentWatch "
 		"(subscriber_id, equipment_id, created, updated) "
 		"VALUES "
-		"(%llu, %llu, datetime('now'), datetime('now')) ",
+		"(%llu, %llu, now(), now()) "
+		"ON DUPLICATE KEY UPDATE updated = now()",
 		subscriber->id, equipment_id);
 	if (!result) {
 		LOGP(DDB, LOGL_ERROR, "Failed to create EquipmentWatch.\n");
@@ -969,7 +983,7 @@ int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM_IM
 	else {
 		result = dbi_conn_queryf(conn,
 			"UPDATE EquipmentWatch "
-			"SET updated = datetime('now') "
+			"SET updated = now() "
 			"WHERE subscriber_id = %llu AND equipment_id = %llu ",
 			subscriber->id, equipment_id);
 		if (!result) {
@@ -1005,7 +1019,7 @@ int db_sms_store(struct gsm_sms *sms)
 		 "reply_path_req, status_rep_req, protocol_id, "
 		 "data_coding_scheme, ud_hdr_ind, dest_addr, "
 		 "user_data, text) VALUES "
-		"(datetime('now'), %llu, %llu, %u, "
+		"(now(), %llu, %llu, %u, "
 		 "%u, %u, %u, %u, %u, %s, %s, %s)",
 		sms->sender->id,
 		sms->receiver ? sms->receiver->id : 0, validity_timestamp,
@@ -1188,7 +1202,7 @@ int db_sms_mark_sent(struct gsm_sms *sms)
 
 	result = dbi_conn_queryf(conn,
 		"UPDATE SMS "
-		"SET sent = datetime('now') "
+		"SET sent = now() "
 		"WHERE id = %llu", sms->id);
 	if (!result) {
 		LOGP(DDB, LOGL_ERROR, "Failed to mark SMS %llu as sent.\n", sms->id);
@@ -1230,7 +1244,7 @@ int db_apdu_blob_store(struct gsm_subscriber *subscr,
 	result = dbi_conn_queryf(conn,
 		"INSERT INTO ApduBlobs "
 		"(created,subscriber_id,apdu_id_flags,apdu) VALUES "
-		"(datetime('now'),%llu,%u,%s)",
+		"(now(),%llu,%u,%s)",
 		subscr->id, apdu_id_flags, q_apdu);
 
 	free(q_apdu);
@@ -1252,7 +1266,7 @@ int db_store_counter(struct counter *ctr)
 	result = dbi_conn_queryf(conn,
 		"INSERT INTO Counters "
 		"(timestamp,name,value) VALUES "
-		"(datetime('now'),%s,%lu)", q_name, ctr->value);
+		"(now(),%s,%lu)", q_name, ctr->value);
 
 	free(q_name);
 
@@ -1275,7 +1289,7 @@ static int db_store_rate_ctr(struct rate_ctr_group *ctrg, unsigned int num,
 	result = dbi_conn_queryf(conn,
 		"Insert INTO RateCounters "
 		"(timestamp,name,idx,value) VALUES "
-		"(datetime('now'),%s.%s,%u,%"PRIu64")",
+		"(now(),%s.%s,%u,%"PRIu64")",
 		q_prefix, q_name, ctrg->idx, ctrg->ctr[num].current);
 
 	free(q_name);
diff --git a/openbsc/include/openbsc/db.h b/openbsc/include/openbsc/db.h
index a939b0d..0de6a99 100644
--- a/openbsc/include/openbsc/db.h
+++ b/openbsc/include/openbsc/db.h
@@ -32,7 +32,7 @@ struct gsm_subscriber;
 enum gsm_subscriber_field;
 
 /* one time initialisation */
-int db_init(const char *name);
+int db_init(const char *name, const char *host, const char *user, const char *passwd);
 int db_prepare();
 int db_fini();
 
