Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Jun 2003
    Location
    Miami, Florida
    Posts
    34

    Thumbs down Backslashed database name .. why?

    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...


  2. #2
    Member
    Join Date
    Jan 2005
    Posts
    1,880

    Default

    An underscore is a wildcard character in MySQL. A backslash is needed before an actual underscore for it to be treated literally.

  3. #3
    Member
    Join Date
    Jun 2003
    Location
    Miami, Florida
    Posts
    34

    Default

    Quote Originally Posted by webignition
    An underscore is a wildcard character in MySQL. A backslash is needed before an actual underscore for it to be treated literally.
    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. #4
    Member
    Join Date
    Jan 2005
    Posts
    1,880

    Default

    Quote Originally Posted by trukfixer
    Show me where in the MySQL manual it is stated?
    The use of the underscore as a wildcard is documented in too many places to mention, for example 13.5.4 SHOW Syntax

    If the syntax for a given SHOW statement includes a LIKE 'pattern' part, 'pattern' is a string that can contain the SQL '%' and '_' wildcard characters. The pattern is useful for restricting statement output to matching values.
    Quote Originally Posted by trukfixer
    ... and if this is so, why is it that usernames are just fine *without* the backslashed underscore??
    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.

    Quote Originally Posted by trukfixer
    Mysql specifically says usernames cannot contain wildcards (MySQL wildcard character is % - Percent symbol- not underscore _ ).
    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.

    Quote Originally Posted by trukfixer
    Still looking for reliable answer .. from someone who knows ...
    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. #5
    Member
    Join Date
    Jun 2003
    Location
    Miami, Florida
    Posts
    34

    Default

    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. #6
    Member
    Join Date
    Jun 2003
    Location
    Miami, Florida
    Posts
    34

    Default

    OK .. never mind finally found it buried in the documentation.

    Note: the '_' and '%' wildcards are allowed when specifying database names in GRANT statements that grant privileges at the global or database levels. This means, for example, that if you want to use a '_' character as part of a database name, you should specify it as '\_' in the GRANT statement, to prevent the user from being able to access additional databases matching the wildcard pattern; for example, GRANT ... ON `foo\_bar`.* TO ....
    Oh well.. guess I'll have to come up with another way of handling things... whee what fun..

Similar Threads & Tags
Similar threads

  1. Replies: 6
    Last Post: 12-21-2010, 12:19 PM
  2. Database Help
    By wedmonds in forum New User Questions
    Replies: 1
    Last Post: 11-03-2009, 09:59 AM
  3. How to do something with Database
    By Gheko in forum Database Discussions
    Replies: 0
    Last Post: 11-22-2007, 06:21 PM
  4. Replies: 0
    Last Post: 05-29-2006, 12:31 PM
  5. because I see the whole database???
    By jedi in forum cPanel and WHM Discussions
    Replies: 8
    Last Post: 09-26-2003, 11:28 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube