Hello,
I have created a bash script to automate some tasks. Part of the script creates a new database and user for a cPanel user. I have the following code:
Everything works as expected, except when I look at the MySQL Databases section the user is not associated with the database. Both the user and database shows up, but the Users column for the database is empty.
None of the following commands have any effect
What am I missing here? Is there some command to make sure the grants show up in cPanel?
As I said, everything works fine with the SQL. Database and user is created correctly, and the user has access to the database, but it does not show up correctly in cPanel.
Any advise will be appreciate.
Thank you,
Sindre
I have created a bash script to automate some tasks. Part of the script creates a new database and user for a cPanel user. I have the following code:
Code:
# Create database and grants
ESCAPED_DB_NAME=${db_name/_/\\_}
Q1="CREATE DATABASE IF NOT EXISTS \`${db_name}\`;"
Q2="GRANT ALL PRIVILEGES ON \`${ESCAPED_DB_NAME}\`.* TO '${db_user}'@'localhost' IDENTIFIED BY '${db_pass}';"
Q3="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}"
mysql -e "$SQL"
# Map new DB to cPanel user
/usr/local/cpanel/bin/dbmaptool $user --type mysql --dbs "${db_name}" --dbusers "${db_user}"
None of the following commands have any effect
Code:
/usr/local/cpanel/bin/dbstoregrants username (this does update the /var/cpanel/databases/grants_username.yaml file correctly)
/usr/local/cpanel/bin/dbindex
/usr/local/cpanel/bin/setupdbmap
As I said, everything works fine with the SQL. Database and user is created correctly, and the user has access to the database, but it does not show up correctly in cPanel.
Any advise will be appreciate.
Thank you,
Sindre
Last edited: