尝试使用fabric设置mysql用户权限。
run("mysql -u %s -p%s -e 'grant all on %s.* to '%s'@'localhost' identified by 'PASSWORD'" % (user, dbpasswd, account))
错误
TypeError: not enough arguments for format string
有什么想法吗?非常感谢!
run('mysql -u %s -p%s -e "grant all on %s.* to '%s\'@\'localhost' identified by 'PASSWORD'"' % (user, dbpasswd, account, account))
SyntaxError: unexpected character after line continuation character
最佳答案
将您的元组更改为(user, dbpasswd, account, user)
,您应该可以了。发生此错误的原因是您有 4 个替换 token (%s),但元组中只有 3 个项目。
关于python Fabric mysql 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11392721/