Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- execute_query()
- {
- echo "Executing $1"
- sudo mysql --execute="$1"
- }
- password=$(< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-64};)
- password="${password}."
- echo
- read -r -p 'Database: ' database
- read -r -p 'Username: ' username
- echo "Password: $password"
- echo
- execute_query "CREATE USER '$username'@'localhost' IDENTIFIED BY '$password';"
- execute_query "GRANT select,update,insert,delete ON $database.* TO '$username'@'localhost';"
- execute_query "FLUSH PRIVILEGES;"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement