{"id":2563,"date":"2024-07-23T03:13:23","date_gmt":"2024-07-23T03:13:23","guid":{"rendered":"https:\/\/pheonixsolutions.com\/knowledge-base\/?p=2563"},"modified":"2024-07-23T03:14:11","modified_gmt":"2024-07-23T03:14:11","slug":"how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/","title":{"rendered":"How to create DB, user and password and give privileges in cpanel using uapi in terminal ?"},"content":{"rendered":"\n<p><strong>Introduction:<\/strong><\/p>\n\n\n\n<p>Managing databases and users on a web hosting server often requires using command-line tools like <code>\/usr\/bin\/uapi<\/code> to automate tasks efficiently. This script demonstrates how to create a MySQL database, create a user, and grant them privileges using the command-line interface.<\/p>\n\n\n\n<p><strong>Prerequisite:<\/strong><\/p>\n\n\n\n<p>Before executing the script, ensure the following prerequisites are met:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Access to Command Line: You should have access to the command line interface of your server or hosting environment where \/usr\/bin\/uapi is installed and accessible.<\/li>\n\n\n\n<li>Credentials: Replace $CPUSER, $DATABASE, $USERNAME, and $PASSWORD with appropriate values:<\/li>\n<\/ol>\n\n\n\n<p>        $CPUSER: The cPanel username associated with the account.<br>        $DATABASE: The name of the MySQL database you want to create.<br>        $USERNAME: The username for the MySQL user you wish to create.<br>        $PASSWORD: The password for the MySQL user.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Permissions: Ensure your user account ($CPUSER) has the necessary permissions to create databases, users, and assign privileges within your hosting environment.<\/li>\n<\/ol>\n\n\n\n<p>Explanation:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create Database:<\/strong> The first command creates a MySQL database named <code>$DATABASE<\/code> under the cPanel user account <code>$CPUSER<\/code>.<\/li>\n\n\n\n<li><strong>Create User:<\/strong> The second command creates a MySQL user with the username <code>$USERNAME<\/code> and assigns the password <code>$PASSWORD<\/code>.<\/li>\n\n\n\n<li><strong>Set Privileges:<\/strong> The third command grants all privileges (<code>ALL PRIVILEGES<\/code>) on the database <code>$DATABASE<\/code> to the user <code>$USERNAME<\/code>, allowing them full access to manage the database.<\/li>\n<\/ol>\n\n\n\n<p><strong>Example:<\/strong><br><br>Run the following command in terminal<br>\/usr\/bin\/uapi &#8211;user=&#8221;username&#8221; &#8211;output=json Mysql create_database name=&#8221;your DB_name&#8221;<br>\/usr\/bin\/uapi &#8211;user=&#8221;username&#8221; &#8211;output=json Mysql create_user name=&#8221;Your DB User&#8221; password=&#8221;Your password&#8221;<br>\/usr\/bin\/uapi &#8211;user=&#8221;username&#8221; Mysql set_privileges_on_database user=&#8221;Your DB User&#8221; database=&#8221;your DB_name&#8221; privileges=ALL PRIVILEGES<br><\/p>\n\n\n\n<p><strong>Conclusion:<\/strong><\/p>\n\n\n\n<p>Automating the creation of MySQL databases and users using command-line tools like <code>\/usr\/bin\/uapi<\/code> streamlines administrative tasks on web hosting servers. By ensuring the prerequisites are met and executing the provided script with appropriate credentials, you can efficiently manage database operations without needing to navigate through graphical user interfaces, thus saving time and effort in server administration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Managing databases and users on a web hosting server often requires using command-line tools like \/usr\/bin\/uapi to automate tasks efficiently. This script demonstrates how to create a MySQL database, create a user, and grant them privileges using the command-line interface. Prerequisite: Before executing the script, ensure the following prerequisites are met: $CPUSER: The cPanel ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[33],"tags":[],"class_list":["post-2563","post","type-post","status-publish","format-standard","hentry","category-whm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to create DB, user and password and give privileges in cpanel using uapi in terminal ? - PheonixSolutions Knowledge-Base<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create DB, user and password and give privileges in cpanel using uapi in terminal ? - PheonixSolutions Knowledge-Base\" \/>\n<meta property=\"og:description\" content=\"Introduction: Managing databases and users on a web hosting server often requires using command-line tools like \/usr\/bin\/uapi to automate tasks efficiently. This script demonstrates how to create a MySQL database, create a user, and grant them privileges using the command-line interface. Prerequisite: Before executing the script, ensure the following prerequisites are met: $CPUSER: The cPanel ..Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/\" \/>\n<meta property=\"og:site_name\" content=\"PheonixSolutions Knowledge-Base\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-23T03:13:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-23T03:14:11+00:00\" \/>\n<meta name=\"author\" content=\"srisanthosh s\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"srisanthosh s\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/\"},\"author\":{\"name\":\"srisanthosh s\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/#\\\/schema\\\/person\\\/070895e04bc57565b04d6106e4da129c\"},\"headline\":\"How to create DB, user and password and give privileges in cpanel using uapi in terminal ?\",\"datePublished\":\"2024-07-23T03:13:23+00:00\",\"dateModified\":\"2024-07-23T03:14:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/\"},\"wordCount\":331,\"commentCount\":0,\"articleSection\":[\"WHM\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/\",\"name\":\"How to create DB, user and password and give privileges in cpanel using uapi in terminal ? - PheonixSolutions Knowledge-Base\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/#website\"},\"datePublished\":\"2024-07-23T03:13:23+00:00\",\"dateModified\":\"2024-07-23T03:14:11+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/#\\\/schema\\\/person\\\/070895e04bc57565b04d6106e4da129c\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/2024\\\/07\\\/23\\\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create DB, user and password and give privileges in cpanel using uapi in terminal ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/#website\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/\",\"name\":\"PheonixSolutions Knowledge-Base\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/#\\\/schema\\\/person\\\/070895e04bc57565b04d6106e4da129c\",\"name\":\"srisanthosh s\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6aaff236b178a614b2cfa9b0388af65e26cb08bb19608a622574904d2765036d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6aaff236b178a614b2cfa9b0388af65e26cb08bb19608a622574904d2765036d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6aaff236b178a614b2cfa9b0388af65e26cb08bb19608a622574904d2765036d?s=96&d=mm&r=g\",\"caption\":\"srisanthosh s\"},\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/knowledge-base\\\/author\\\/srisanthosh\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create DB, user and password and give privileges in cpanel using uapi in terminal ? - PheonixSolutions Knowledge-Base","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/","og_locale":"en_US","og_type":"article","og_title":"How to create DB, user and password and give privileges in cpanel using uapi in terminal ? - PheonixSolutions Knowledge-Base","og_description":"Introduction: Managing databases and users on a web hosting server often requires using command-line tools like \/usr\/bin\/uapi to automate tasks efficiently. This script demonstrates how to create a MySQL database, create a user, and grant them privileges using the command-line interface. Prerequisite: Before executing the script, ensure the following prerequisites are met: $CPUSER: The cPanel ..Read more","og_url":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/","og_site_name":"PheonixSolutions Knowledge-Base","article_published_time":"2024-07-23T03:13:23+00:00","article_modified_time":"2024-07-23T03:14:11+00:00","author":"srisanthosh s","twitter_card":"summary_large_image","twitter_misc":{"Written by":"srisanthosh s","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/#article","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/"},"author":{"name":"srisanthosh s","@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/#\/schema\/person\/070895e04bc57565b04d6106e4da129c"},"headline":"How to create DB, user and password and give privileges in cpanel using uapi in terminal ?","datePublished":"2024-07-23T03:13:23+00:00","dateModified":"2024-07-23T03:14:11+00:00","mainEntityOfPage":{"@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/"},"wordCount":331,"commentCount":0,"articleSection":["WHM"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/","url":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/","name":"How to create DB, user and password and give privileges in cpanel using uapi in terminal ? - PheonixSolutions Knowledge-Base","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/#website"},"datePublished":"2024-07-23T03:13:23+00:00","dateModified":"2024-07-23T03:14:11+00:00","author":{"@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/#\/schema\/person\/070895e04bc57565b04d6106e4da129c"},"breadcrumb":{"@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/2024\/07\/23\/how-to-create-db-user-and-password-and-give-privileges-in-cpanel-using-uapi-in-terminal\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pheonixsolutions.com\/knowledge-base\/"},{"@type":"ListItem","position":2,"name":"How to create DB, user and password and give privileges in cpanel using uapi in terminal ?"}]},{"@type":"WebSite","@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/#website","url":"https:\/\/pheonixsolutions.com\/knowledge-base\/","name":"PheonixSolutions Knowledge-Base","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pheonixsolutions.com\/knowledge-base\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/pheonixsolutions.com\/knowledge-base\/#\/schema\/person\/070895e04bc57565b04d6106e4da129c","name":"srisanthosh s","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/6aaff236b178a614b2cfa9b0388af65e26cb08bb19608a622574904d2765036d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6aaff236b178a614b2cfa9b0388af65e26cb08bb19608a622574904d2765036d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6aaff236b178a614b2cfa9b0388af65e26cb08bb19608a622574904d2765036d?s=96&d=mm&r=g","caption":"srisanthosh s"},"url":"https:\/\/pheonixsolutions.com\/knowledge-base\/author\/srisanthosh\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=2563"}],"version-history":[{"count":4,"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2563\/revisions"}],"predecessor-version":[{"id":2570,"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2563\/revisions\/2570"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=2563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=2563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=2563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}