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.

Mysql database creation

Discussion in 'Database Discussions' started by manish294, Aug 28, 2016.

  1. manish294

    manish294 Member

    Joined:
    Jul 5, 2016
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi All,

    I am trying to create mysql database from command line from user shell but receiving below errors:

    ==============================
    MariaDB [(none)]> create database user_test12;
    ERROR 1044 (42000): Access denied for user 'user'@'localhost' to database 'user_test12'
    ==============================

    I have then tried to assign CREATE grant to the cpanel user:

    GRANT CREATE ON *.* TO 'user'@'localhost';

    By this user was able to create database but it gives access of all databases on server to the user.

    I want to assign CREATE grant to the user to create the database but I don't want to give access of all databases on the server to user.

    Please help me.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. manish294

    manish294 Member

    Joined:
    Jul 5, 2016
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi cPanelMichael,

    Thank you for the details and it worked :)

    But only one problem, if cpanel user logged in to shell uapi command is not working for them. Its running only from root.

    I have shared server so I can only give access of Jailed Shell or normal shell to users.

    Is there no way to create database from mysql prompt from user shell login ?(not from root)

    Thanks in advance :)
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    Ensure you use the following command while logged in as the account username via SSH:

    Code:
    uapi Mysql create_database name=database_name
    The "--user=username" parameter isn't required if you are already logged in as the account username.

    Thank you.
     
  5. manish294

    manish294 Member

    Joined:
    Jul 5, 2016
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello cPanelMichael,

    Thank you.

    I have tried the provided command but received below errors:
    ================
    -jailshell: uapi: command not found
    ================

    When I assigned normal shell to user its showing below error
    ================
    -bash: uapi: command not found
    ================

    Even I tried to run /usr/bin/uapi from user shell and its not working.

    I am sure if uapi command runs in user shell the provided command by you will work.
    Any help regarding running uapi command from user shell would be great full.

    Thanks again :)
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    cPanel & WHM introduced the UAPI command line feature in version 56. Could you verify if this system uses cPanel version 56 or newer?

    Code:
    cat /usr/local/cpanel/version
    Thank you.
     
  7. manish294

    manish294 Member

    Joined:
    Jul 5, 2016
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi cPanelMichael,

    Yes, I have latest version of cpanel installed on the server.
    ========================
    root@[~]# cat /usr/local/cpanel/version
    11.58.0.26
    ========================
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Could you open a support ticket using the link in my signature so we can determine why UAPI isn't working via the command line? You can post the ticket number here so we can update this thread with the outcome.

    Thank you.
     
  9. manish294

    manish294 Member

    Joined:
    Jul 5, 2016
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi cPanelMichael,

    I will open a support ticket soon and update this thread.
     
  10. manish294

    manish294 Member

    Joined:
    Jul 5, 2016
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi cPanelMichael,

    I have an update. Before opening a support ticket I investigated further and noticed that uapi was not working because of cagefs.
    I have cloudlinux on my server and cagefs was enabled for user. Due to which uapi command was not working.

    It's working when I disabled the cagefs for user and yes it's creating database through the command you gave me :)

    Thank you again :)
     
  11. Bazinga

    Bazinga Active Member

    Joined:
    Aug 23, 2016
    Messages:
    26
    Likes Received:
    5
    Trophy Points:
    3
    Location:
    Ukraine
    cPanel Access Level:
    Website Owner
    there is a way to fix it:
    - install cagefs and PHP-Selector (if not yet installed)
    - change php version for all native version back to 5.3 with command:
    selectorctl --change-to-version=5.3 --version=native
     
Loading...

Share This Page