Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Create MySQL Database & User via Shell

Discussion in 'Database Discussion' started by Arhineus, Oct 11, 2007.

  1. Arhineus

    Arhineus Well-Known Member

    Joined:
    Nov 1, 2005
    Messages:
    58
    Likes Received:
    0
    Trophy Points:
    156
    I'm trying to assign a MySQL database & MySQL user to a cPanel account via SSH.

    I believe the correct syntax to be the following.

    > create database account_dbname;
    > GRANT ALL PRIVILEGES ON account_dbname.* TO 'account_dbuser'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

    When I go into the cPanel account to make sure I've done it correctly, the user doesn't seam to be assigned to the database. Have I got something wrong here?
     
  2. madaboutlinux

    madaboutlinux Well-Known Member

    Joined:
    Jan 24, 2005
    Messages:
    1,051
    Likes Received:
    2
    Trophy Points:
    168
    Location:
    Earth
    When you create a database and assign a user from shell a back slash (\) get missed in the database name in the 'db' table. Connect to Mysql and execute the command:

    mysql> use mysql;

    mysql> select * from db;

    Check the 'Db' field and you will see a slash missing. The database name should be changed to 'account\_dbname' and at the moment it should be 'account_dbname'. Execute the below query and you will see the user assigned to database in cPanel.

    update db set Db='account\_dbname' where User='account_dbuser';

    This should fix the issue.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice