Created
January 5, 2012 22:44
-
-
Save whazor/1567743 to your computer and use it in GitHub Desktop.
MySQL user generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>mySQL user generator</title> | |
<style> | |
body, html { | |
background-color: #E3E3E3; | |
font: normal normal normal 1em Arial, sans-serif; | |
} | |
label { | |
display: block; | |
font-weight: bold; | |
} | |
#content { | |
background-color: #F8F8F8; | |
border-radius: 10px; | |
padding: 30px; | |
margin: 50px auto; | |
width: 700px; | |
} | |
textarea { | |
width: 99%; | |
height: 100px; | |
} | |
</style> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script> | |
$(function(){ | |
$('input').bind('keyup', function(){ | |
var username = $('[name=username]').val(); | |
var password = $('[name=password]').val(); | |
var database = $('[name=database]').val(); | |
$("[name=sql]").val( | |
"CREATE USER '"+username+"'@'localhost' IDENTIFIED BY '"+password+"';\n"+ | |
"GRANT USAGE ON * . * TO '"+username+"'@'localhost' IDENTIFIED BY '"+password+"' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;\n"+ | |
"GRANT ALL PRIVILEGES ON `"+database+"` . * TO '"+username+"'@'localhost';" | |
); | |
}); | |
$('[name=username]').bind('keyup', function() { | |
$('[name=database]').val($(this).val()+'\\_%'); | |
$('[name=database]').trigger('keyup'); | |
}); | |
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; | |
var pass = ''; | |
for (var i=0; i < 30; i++) { | |
var rnum = Math.floor(Math.random() * chars.length); | |
pass += chars.substring(rnum, rnum+1); | |
} | |
$("[name=password]").val(pass); | |
$("[name=username]").focus(); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="content"> | |
<label for="username">Username</label><input name="username" value="user" /> | |
<label for="password">Password</label><input name="password" value="" /> | |
<label for="database">Database</label><input name="database" value="user\_%" /> | |
<label for="sql">SQL</label> | |
<textarea name="sql"></textarea> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment