diff --git a/product/ERP5Type/tests/ERP5TypeTestCase.py b/product/ERP5Type/tests/ERP5TypeTestCase.py
index 27c981bfeadd25221d30f14b4bdd8b31dd256245..a148742ebfa544e12404fddbd97a795a5f1abf49 100644
--- a/product/ERP5Type/tests/ERP5TypeTestCase.py
+++ b/product/ERP5Type/tests/ERP5TypeTestCase.py
@@ -25,6 +25,7 @@ Globals.get_request = get_request
 
 from Testing import ZopeTestCase
 from Testing.ZopeTestCase.PortalTestCase import PortalTestCase, user_name
+from Products.ERP5Type.tests.utils import getMySQLArguments
 from Products.CMFCore.utils import getToolByName
 from Products.ERP5Type.Utils import getLocalPropertySheetList, \
                                     removeLocalPropertySheet, \
@@ -137,21 +138,17 @@ from Products.ERP5Type.InitGenerator import initializeProductDocumentRegistry
 initializeProductDocumentRegistry()
 
 from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
-from AccessControl.User import User
 
 from Acquisition import aq_base
 import time
 import md5
 import traceback
-import sys
 import os
 from cStringIO import StringIO
 from urllib import urlretrieve
 from glob import glob
 import pysvn
 
-from Products.ERP5.ERP5Site import ERP5Site
-
 portal_name = 'erp5_portal'
 
 # we keep a reference to all sites for wich setup failed the first time, to
@@ -188,7 +185,8 @@ class ERP5TypeTestCase(PortalTestCase):
 
     def getRevision(self):
       try:
-        return pysvn.Client().info('%s/Products/ERP5' % os.environ['INSTANCE_HOME']).revision.number
+        return pysvn.Client().info('%s/Products/ERP5'
+                    % os.environ['INSTANCE_HOME']).revision.number
       except:
         return None
 
@@ -602,7 +600,8 @@ def setupERP5Site( business_template_list=(),
             if not quiet:
               ZopeTestCase._print('Dumping MySQL database ... ')
             instance_home = os.environ['INSTANCE_HOME']
-            os.system('mysqldump -u test test > %s/dump.sql' % instance_home)
+            os.system('mysqldump %s > %s/dump.sql' % (
+                      getMySQLArguments(), instance_home))
             if not quiet:
               ZopeTestCase._print('Dumping static files ... ')
             for dir in ('Constraint', 'Document', 'PropertySheet'):
diff --git a/product/ERP5Type/tests/custom_zodb.py b/product/ERP5Type/tests/custom_zodb.py
index adfdccb960d3af0a2f3fa9f73f50fe78c05cdd04..acc954b8576ae209a5167d344b56ae2d0697ac81 100644
--- a/product/ERP5Type/tests/custom_zodb.py
+++ b/product/ERP5Type/tests/custom_zodb.py
@@ -2,6 +2,7 @@ import ZODB
 import os
 from ZODB.DemoStorage import DemoStorage
 from ZODB.FileStorage import FileStorage
+from Products.ERP5Type.tests.utils import getMySQLArguments
 
 instance_home = os.environ.get('INSTANCE_HOME')
 data_fs_path = os.environ.get('erp5_tests_data_fs_path')
@@ -17,7 +18,7 @@ elif os.environ.get('erp5_load_data_fs'):
   else:
     Storage = DemoStorage(base=FileStorage(new_data_fs_path), quota=(1<<20))
   print("Restoring MySQL database ... ")
-  os.system("mysql -u test test < %s/dump.sql" % instance_home)
+  os.system("mysql %s < %s/dump.sql" % (getMySQLArguments(), instance_home))
   print("Restoring static files ... ")
   for dir in ('Constraint', 'Document', 'PropertySheet'):
     if os.path.exists('%s/%s.bak' % (instance_home, dir)):
diff --git a/product/ERP5Type/tests/utils.py b/product/ERP5Type/tests/utils.py
index 20cdb33c7bd85102c2ffd17a32f49dc8c87d1368..42a44f545ae736fd06d886db303612340eb05166 100644
--- a/product/ERP5Type/tests/utils.py
+++ b/product/ERP5Type/tests/utils.py
@@ -29,6 +29,8 @@
 """Utility functions and classes for unit testing
 """
 
+import os
+
 import Products.ERP5Type
 from Products.MailHost.MailHost import MailHost
 
@@ -108,6 +110,18 @@ def _recreateMemcachedTool(portal):
   portal.manage_delObjects(['portal_memcached'])
   portal._setObject('portal_memcached', MemcachedTool.MemcachedTool())
 
+# test runner shared functions
+def getMySQLArguments():
+  """Returns arguments to pass to mysql by heuristically converting the
+  connection string.
+  Only simple cases are coverred for now.
+  """
+  connection_string = os.environ.get('erp5_sql_connection_string')
+  if not connection_string:
+    return '-u test test'
+  db, user = connection_string.split()
+  return '-u %s %s' % (user, db)
+
 # decorators
 class reindex(object):
   """Decorator to commit transaction and flush activities after the method is