XML API 2. Bring the mysql db prefix
Hey, thanks for reading this.
I'm working with the XML API 2 in PHP. I have developed a module where I created dbs dynamically. It happens I need to know the Mysql required prefix before creating the database, because sometimes it does not match with the cpanel user.
Do you know anyway/method allowing me to discover this prefix?
-
Hello, Each new database name or database username begins with the first eight characters of the account username and an underscore (_) when prefixing is enabled. Thus, if the username is abcdefghi, the prefix name is abcdefgh. Thank you. 0 -
Thanks for your response. Yes, I was already assuming that. But it seems some cpanels have a custom prefix set for the db names that's even beyond the 8 chars. I'll see how can I deal with it then. Thanks for your answer. 0 -
Yes, I was already assuming that. But it seems some cpanels have a custom prefix set for the db names that's even beyond the 8 chars.
This is unsupported, and should only happen if database prefixing is disabled and the user chooses to create a database name with an underscore. You may also want to consider disabling database prefixing completely by turning off "Require a username prefix on names of new databases and database users" in "WHM >> Tweak Settings" under the "SQL" tab. Thank you.0 -
Ok, I see. You can remove my previous comment. So is this something I can query through the API. I mean if the prefix setting is on or off? 0 -
So is this something I can query through the API. I mean if the prefix setting is on or off?
Hello, Yes, you can use the following UAPI function for this purpose: UAPI Functions - Mysql::get_restrictions - Software Development Kit - cPanel Documentation View the "Prefix" row under the "Returns" section of this document for information on how to tell if prefixing is enabled. Thanks!0
Please sign in to leave a comment.
Comments
5 comments