Index: trac/db/mysql_backend.py
===================================================================
--- trac/db/mysql_backend.py	(revision 6299)
+++ trac/db/mysql_backend.py	(working copy)
@@ -148,22 +148,40 @@
 
         if path.startswith('/'):
             path = path[1:]
-        if password == None:
-            password = ''
-        if port == None:
-            port = 3306
 
         # python-mysqldb 1.2.1 added a 'charset' arg that is required for
         # unicode stuff.  We hack around that here for older versions; at
         # some point, this hack should be removed, and a strict requirement
         # on 1.2.1 made.  -dilinger
+        
+        # the 'params' variable really should be passed to mysqldb
+        # this is a hack to add my.cnf support
+        change_charset = 0
         if (self._mysqldb_gt_or_eq((1, 2, 1))):
-            cnx = MySQLdb.connect(db=path, user=user, passwd=password,
-                                  host=host, port=port, charset='utf8')
+            params['charset'] = 'utf8'
         else:
-            cnx = MySQLdb.connect(db=path, user=user, passwd=password,
-                                  host=host, port=port, use_unicode=True)
+            change_charset = 1
+            params['use_unicode'] = True
+
+        # don't want to pass these if they are None, the library will complain.
+        if password != None:
+            params['passwd'] = password
+        if user != None:
+            params['user'] = user
+        if host != None:
+            params['host'] = host
+        if port != None:
+            params['port'] = port
+        if path != None:
+            params['db'] = path
+
+        # removes encoding?
+        strparams = dict([(str(x),params[x]) for x in params.keys()])
+        cnx = MySQLdb.connect( **strparams )
+        
+        if change_charset:
             self._set_character_set(cnx, 'utf8')
+
         ConnectionWrapper.__init__(self, cnx)
         self._is_closed = False
 

