Database user not being associated with database
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
# 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}"
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
/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
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
-
Hello :) Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome. Thank you. 0 -
Thanks. Ticket has been created: 4516311 0 -
To update, it was determined that the issue could not be reproduced on a standard MySQL installation with cPanel. The server in question was using Percona, which possibly contributed to the issue. The user was able to implement a solution through the edit of the /var/cpanel/databases/$user.cache and /var/cpanel/databases/$user.yaml files. Thank you. 0
Please sign in to leave a comment.
Comments
3 comments