diff --git a/mysql_db b/mysql_db index 07d4374546b..1e98c3676c0 100755 --- a/mysql_db +++ b/mysql_db @@ -47,10 +47,10 @@ def db_create(cursor, db): def load_mycnf(): config = ConfigParser.RawConfigParser() mycnf = os.path.expanduser('~/.my.cnf') - config.read(mycnf) try: + config.readfp(open(mycnf)) creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'pass')) - except ConfigParser.NoOptionError: + except (ConfigParser.NoOptionError, IOError): return False return creds diff --git a/mysql_user b/mysql_user index 385f48faa94..7ae3cb6363c 100755 --- a/mysql_user +++ b/mysql_user @@ -145,10 +145,10 @@ def privileges_grant(cursor, user,host,db_table,priv): def load_mycnf(): config = ConfigParser.RawConfigParser() mycnf = os.path.expanduser('~/.my.cnf') - config.read(mycnf) try: + config.readfp(open(mycnf)) creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'pass')) - except ConfigParser.NoOptionError: + except (ConfigParser.NoOptionError, IOError): return False return creds