Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Feb 2005
    Posts
    219

    Default MySQL database / username connection

    Hi -

    If I run these .sql queries in this order:

    Code:
    CREATE DATABASE `username1_dbname`;
    GRANT ALL ON `username1_dbname`.* TO 'username1_foo'@'localhost' IDENTIFIED BY 'lskdfj';
    FLUSH PRIVILEGES;
    It works. The user can now use this database, dbname, and db pass however they like.

    But in cPanel's MySQL panel, the db account name and the database both appear, but don't appear connected - it appears as if that user has no grants on that db. I would assume cPanel would show the grant as already existing.

    How can I run a series of SQL statement as above that not only works, but also displays properly in cPanel? What is cPanel checking for when displaying grants between db account names and databases?

    Thanks,
    Scot

  2. #2
    Member
    Join Date
    Feb 2005
    Posts
    219

    Default

    OK - After much trial and error, I've solve this one. You need to escape the underscore in the GRANT statement line. You do NOT need to escape the underscore in the CREATE DATABASE line. Go figure. so this code gets it right (the change is in red below):

    Code:
    CREATE DATABASE `username1_dbname`;
    GRANT ALL ON `username1\_dbname`.* TO 'username1_foo'@'localhost' IDENTIFIED BY 'lskdfj';
    FLUSH PRIVILEGES;
    I have no idea why this is necessary. Again, the original version works just fine, it's just that the graphical cPanel database admin user page does not show the connection between the username and the db name unless you do the escaping as above. Quirky.

Similar Threads & Tags
Similar threads

  1. Magento Database connection
    By tostrye in forum New User Questions
    Replies: 3
    Last Post: 03-09-2011, 09:52 AM
  2. Database connection help
    By William_Wallace in forum Database Discussions
    Replies: 1
    Last Post: 02-11-2009, 02:49 PM
  3. Replies: 0
    Last Post: 02-02-2009, 08:17 AM
  4. PHP, MySQL Database Connection Problem
    By pl0tted in forum Database Discussions
    Replies: 1
    Last Post: 01-18-2009, 02:12 PM
  5. Database Connection Question
    By N9ne in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 08-28-2003, 09:18 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube