SOLVED XML API 2. Bring the mysql db prefix

markskayff

Registered
Dec 4, 2016
3
0
1
Montevideo
cPanel Access Level
Website Owner
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?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
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.
 
  • Like
Reactions: markskayff

markskayff

Registered
Dec 4, 2016
3
0
1
Montevideo
cPanel Access Level
Website Owner
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,218
463