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

    Default Create MySQL Database & User via Shell

    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. #2
    Member
    Join Date
    Jan 2005
    Location
    Earth
    Posts
    1,050

    Default

    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.

Similar Threads & Tags
Similar threads

  1. Replies: 2
    Last Post: 10-24-2011, 02:13 PM
  2. How to Suspend user Mysql database Auto if use high cpu & memory
    By onel0ve in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 05-30-2011, 02:31 AM
  3. Automatically create mysql user and database for new WHM accounts?
    By joachim.n in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 06-19-2009, 11:14 AM
  4. mySQL user which can create new database
    By awa in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-23-2008, 04:58 AM
  5. MySQL user priviledges & database itself
    By s.herzig in forum Database Discussions
    Replies: 4
    Last Post: 05-29-2008, 05:54 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube