Merge pull request #2175 from tyll/devel
mysql_db/user: Use password for my.cnf
This commit is contained in:
commit
e4e17d9ac1
2 changed files with 9 additions and 3 deletions
2
mysql_db
2
mysql_db
|
@ -131,7 +131,7 @@ def load_mycnf():
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
config.readfp(open(mycnf))
|
config.readfp(open(mycnf))
|
||||||
creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'pass'))
|
creds = dict(user=config.get('client', 'user'),passwd=config.get('client', 'password'))
|
||||||
except (ConfigParser.NoOptionError, IOError):
|
except (ConfigParser.NoOptionError, IOError):
|
||||||
return False
|
return False
|
||||||
return creds
|
return creds
|
||||||
|
|
10
mysql_user
10
mysql_user
|
@ -213,7 +213,13 @@ def privileges_revoke(cursor, user,host,db_table):
|
||||||
query = "REVOKE ALL PRIVILEGES ON %s FROM '%s'@'%s'" % (db_table,user,host)
|
query = "REVOKE ALL PRIVILEGES ON %s FROM '%s'@'%s'" % (db_table,user,host)
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
query = "REVOKE GRANT OPTION ON %s FROM '%s'@'%s'" % (db_table,user,host)
|
query = "REVOKE GRANT OPTION ON %s FROM '%s'@'%s'" % (db_table,user,host)
|
||||||
cursor.execute(query)
|
try:
|
||||||
|
cursor.execute(query)
|
||||||
|
except MySQLdb.OperationalError, e:
|
||||||
|
# 1141 -> There is no such grant defined for user ... on host ...
|
||||||
|
# If this exception is raised, there is no need to revoke the GRANT privilege
|
||||||
|
if e.args[0] != 1141 or not e.args[1].startswith("There is no such grant defined for user"):
|
||||||
|
raise e
|
||||||
|
|
||||||
def privileges_grant(cursor, user,host,db_table,priv):
|
def privileges_grant(cursor, user,host,db_table,priv):
|
||||||
|
|
||||||
|
@ -230,7 +236,7 @@ def load_mycnf():
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
config.readfp(open(mycnf))
|
config.readfp(open(mycnf))
|
||||||
creds = dict(user=config.get('client', 'user'),password=config.get('client', 'pass'))
|
creds = dict(user=config.get('client', 'user'),password=config.get('client', 'password'))
|
||||||
except (ConfigParser.NoOptionError, IOError):
|
except (ConfigParser.NoOptionError, IOError):
|
||||||
return False
|
return False
|
||||||
return creds
|
return creds
|
||||||
|
|
Loading…
Reference in a new issue