Database creator.
<3
:1

Date posted: Nov. 27, 2022, 12:05 a.m.
Problem: need a databse, don't want to leave cli.
What does it do?: creates a database in the cPanel with a user and full privileges. Takes a suffix and creates a random password.
Problem: need a databse, don't want to leave cli.
What does it do?: creates a database in the cPanel with a user and full privileges. Takes a suffix and creates a random password.
sean@castle-murray.com[~/uapi/cpanel/bash] #
( read -p "Database suffix: " sfx pfx=$(uapi Mysql get_restrictions|awk '/prefix/ {print $2}') name="${pfx}${sfx}" pw=$(head /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c15) uapi Mysql create_database name="${name}" uapi Mysql create_user name="${name}" password="${pw}" uapi Mysql set_privileges_on_database user="${name}" database="${name}" privileges=ALL echo "Database and user name: "${name}"" echo "password: "${pw}"" unset pw )