def list_users_with_grants(mydb):
    """
    Get an array of tuples containing database users and their databases.

    Args:
        mydb - A connected MySQL connection

    Return:
        An array of tuples ( user, host, database )
    """
    databases = []
    cursor = mydb.cursor()
    cursor.execute('SELECT User, Host, Db FROM mysql.db WHERE User<>"root";')
    while True:
        rows = cursor.fetchmany(20)
        if not rows:
            break
        for rowset in rows:
            user = rowset[0].decode("utf-8")
            host = rowset[1].decode("utf-8")
            database = rowset[2].decode("utf-8")
            databases.append(( user, host, database ))
    return databases