I have the following PHP code that I use to create a database, user and user permissions:
$con = mysql_connect("IP.ADDRESS","user","pass");
mysql_query("CREATE DATABASE ".$dbuser."",$con)or die(mysql_error());
mysql_query("grant all on ".$dbuser.".* to ".$dbname." identified by '".$dbpass."'",$con) or die(mysql_error());
I want to follow the same steps, but from within the shell script. This is something like this:
MyUSER="user"
MyPASS="pass"
MYSQL -u $MyUSER -h -p$MyPASS -Bse "CREATE DATABASE $dbuser;"
MYSQL -u $MyUSER -h -p$MyPASS -Bse "GRANT ALL ON $DBUSER.* to $DBNAME identified by $DBPASS;"
EDIT as this is necessary in postwwwacct (cPanel post script account creation hook), ideally it will be completely self-contained
source
share