The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED XML API 2. Bring the mysql db prefix

Discussion in 'cPanel Developers' started by markskayff, Dec 4, 2016.

Tags:
  1. markskayff

    markskayff Registered

    Joined:
    Dec 4, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
    markskayff likes this.
  3. markskayff

    markskayff Registered

    Joined:
    Dec 4, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
  5. markskayff

    markskayff Registered

    Joined:
    Dec 4, 2016
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Montevideo
    cPanel Access Level:
    Website Owner
    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?
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page