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.

Create MySQL Database & User via Shell

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

  1. Arhineus

    Arhineus Well-Known Member

    Joined:
    Nov 1, 2005
    Messages:
    58
    Likes Received:
    0
    Trophy Points:
    6
    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,052
    Likes Received:
    2
    Trophy Points:
    38
    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.
     
Loading...

Share This Page