feerdispzoo
Verified User
- Joined
- Jan 17, 2022
- Messages
- 189
/directadmin/scripts/custom/domain_create_post.sh
variables:
This code should create database, user and password:
But result is: only database created without user and password:
also we try this:
and the same result:
database created, without user
Does any know what is wrong with this code?
variables:
Code:
dbpass=$(openssl rand -base64 12) > /dev/null
ext=$(openssl rand -hex 2) > /dev/null
dbuser="wp${ext}" # do not include the username_ for dataskq here as DA adds this
wpconfigdbuser="${username}_wp${ext}"
wpadminpass=$(openssl rand -base64 14) > /dev/null
This code should create database, user and password:
Code:
/usr/bin/mysqladmin -uda_admin -p$(cat /usr/local/directadmin/conf/mysql.conf | grep pass | cut -d\= -f2 ) create ${wpconfigdbuser};
echo "CREATE USER ${wpconfigdbuser} IDENTIFIED BY '${dbpass}';" | mysql -uda_admin -p$(cat /usr/local/directadmin/conf/mysql.conf | grep pass | cut -d\= -f2 );
echo "GRANT ALL PRIVILEGES ON ${wpconfigdbuser}.* TO ${wpconfigdbuser} IDENTIFIED BY '${dbpass}
But result is: only database created without user and password:
also we try this:
Code:
# read mysql access stuff
DA_MYSQL=/usr/local/directadmin/conf/mysql.conf
DA_USER=`cat $DA_MYSQL | grep user= | cut -d= -f2`
DA_PASS=`cat $DA_MYSQL | grep passwd= | cut -d= -f2`
NEW_DB="${username}_db1"
NEW_USER="${username}@localhost"
# create database
mysql -u $DA_USER -p$DA_PASS --execute="CREATE DATABASE $NEW_DB"
#create user
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"
#create default user
NEW_USER="${username}_usr@localhost"
mysql -u $DA_USER -p$DA_PASS --execute="GRANT ALL on $NEW_DB.* to $NEW_USER identified by '${passwd}'"
and the same result:
database created, without user
Does any know what is wrong with this code?