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.

Backslashed database name .. why?

Discussion in 'General Discussion' started by trukfixer, Apr 9, 2005.

  1. trukfixer

    trukfixer Active Member

    Joined:
    Jun 27, 2003
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Miami, Florida
    Just curiuos about this. but why on earth does CPanel add a backslash to the _ underscore when creating a database?

    select * from db;

    +------------------------------+
    | db |
    +-------------------------------+
    | dbprefix\_dbname |
    +-------------------------------+

    note the backslashed underscore..

    Why?? What's the point? as far as I can tell , it's completely useless and un-necessary...

    :confused: :confused:
     
  2. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    An underscore is a wildcard character in MySQL. A backslash is needed before an actual underscore for it to be treated literally.
     
  3. trukfixer

    trukfixer Active Member

    Joined:
    Jun 27, 2003
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Miami, Florida
    Based on what information?? Show me where in the MySQL manual it is stated? and if this is so, why is it that usernames are just fine *without* the backslashed underscore??

    Mysql specifically says usernames cannot contain wildcards :) (MySQL wildcard character is % - Percent symbol- not underscore _ )

    Still looking for reliable answer .. from someone who knows :) ...

    been through the MySQL manual.. CPanel enabled machines are the only ones Ive seen that have this idiosyncracy .. Mind you, I run several, including machines with Plesk ,WebMin and Ensim .. and plain-vanilla "No ControlPanel" webservers (Running Debian Sarge Kernel, no Control Panel of any kind)... and none.. mind you.. *None* of those mysql installations (also running the same version of MySQL as running on the CPanel machine) has that issue.. it is *exclusive* to CPanel :)


    Bri!
     
  4. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    The use of the underscore as a wildcard is documented in too many places to mention, for example 13.5.4 SHOW Syntax

    I believe that the underscore for use as a wildcard is only applicable to database names, table names and column names and hence not relevant to usernames.

    This is most likely true. Your original example related to an underscore in a database name. I don't see how the format of usernames comes into this.

    I'm happy to help if you're willing to listen. I wouldn't have posted my original answer if I wasn't certain. If I had any doubt, as is often the case, I would have stated that I wasn't certain or that it was a guess.

    I hope this clarifies things and that it helps!
     
  5. trukfixer

    trukfixer Active Member

    Joined:
    Jun 27, 2003
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Miami, Florida
    Still isnt an accurate answer .. the question being.. "WHY is it backslashed *IN* the database table rows itself"

    The use of a "wildcard" being backslashed is for use in a *command* or *query* .. not used for storage...

    as I showed in my original post.. a result set is returned *SHOWING* the backslash being stored in the database..

    You see, I have been working very intensively with MySQL..

    MySQL version 4.1.23 on debian , and many other machines, I use the "SHOW DATABASES" query to get a list of table names and parse it out...(and then select where db=value from users table, to get a list of grants) and until this situation with a CPanel enabled server, (also running MySQL 4.1.23 ) there has *never* been a backslashed underscore * IN* the database result set

    You are answering a question I *did not* ask.. - not answering the original question

    You are talking about the use of an underscore as a wildcard in a statement or query ..

    I am talking about the underscore being backslashed *** IN the result set ***

    I.E:

    debian server, no control panel of any type, no cpanel , mysql 4.1.23
    Code:
    mysql> select db from db;
    +-------------+
    | db          |
    +-------------+
    | test        |
    | ****_game1  |
    | ****_game2  |
    
    
    Notice, the database names are *NOT* backslashed

    (obviously the prefix shown as ***** for security reasons)

    Now.. going to the CPanel enabled server..

    Code:
    mysql> select db from db;
    +----------------------+
    | db                   |
    +----------------------+
    | test                 |
    | test\_%              |
    | *****\_avsfinder     |
    | *****\_avsfinder     |
    
    
    What I am asking for is an explanation as to *why* CPanel does THAT - , because the issue *only* shows up on CPanel servers, no other servers that I work with... and MySQL manual shows no requirement whatsoever that said database names contained in db table should be escaped - no one else does, *including* mysql itself..

    This is a totally non-standard implementation that I am rather convinced is a *bug* in CPanel, otherwise, I would lik eto know the purpose and/or reasoning behind the storage of a database name *containing* a backslash

    it makes absolutely no sense to me ..
     
  6. trukfixer

    trukfixer Active Member

    Joined:
    Jun 27, 2003
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Miami, Florida
    OK .. never mind finally found it buried in the documentation.

    Oh well.. guess I'll have to come up with another way of handling things... whee what fun..
     
Loading...

Share This Page