{"id":655,"date":"2018-06-08T12:57:07","date_gmt":"2018-06-08T12:57:07","guid":{"rendered":"https:\/\/www.dewlance.com\/kb\/?p=655"},"modified":"2022-08-16T11:12:20","modified_gmt":"2022-08-16T11:12:20","slug":"creating-new-user-and-grant-permission-in-mysql-mariadb","status":"publish","type":"post","link":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb","title":{"rendered":"Creating new user and grant permission in MySQL\/MariaDB &#8211; VPS"},"content":{"rendered":"<p>Creating a new user and allocating a set of permissions are the first steps you must take when you install a new application that operates based on MySQL\/MariaDB database engine. The guide provides tutorial on how to do this via the MySQL command line interface or other tools that allow the execution of SQL commands<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-656\" src=\"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif\" alt=\"\" width=\"545\" height=\"226\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4>Step One: Adding a New Database<\/h4>\n<p>To add a new database, you must type the following command line:<\/p>\n<pre>mysql&gt; CREATE DATABASE `mydb`;<\/pre>\n<p>&nbsp;<\/p>\n<h5>Step Two: Adding a New User to the Database<\/h5>\n<p>After the database is created, it is time to add a new user to it. You must add the user so that he can login and access its features. To add a new user, you simply type the command line:<\/p>\n<pre>mysql&gt; CREATE USER 'myuser' IDENTIFIED BY 'mypassword';<\/pre>\n<p>&nbsp;<\/p>\n<p>You are to replace myuser with your preferred MySQL username and mypassword with a strong password. If you don&#8217;t want to assign any password, you just leave the mypassword area empty. This means that the user can login into the database without the need of entering any password.<\/p>\n<p>&nbsp;<\/p>\n<p>To check whether you have added a new user correctly, you must first log out by entering the command:<\/p>\n<pre>mysql&gt; quit<\/pre>\n<p>&nbsp;<\/p>\n<p>After logging out, you must login with the new username and password that you&#8217;ve just created:<\/p>\n<pre>mysql -u UserNameHere -p<\/pre>\n<p>&nbsp;<\/p>\n<h5>Step Three: Allocating Permissions to the New User<\/h5>\n<p>Right now, you have created a new user but he can&#8217;t access any function of the database until you grant him the permission to do so.<\/p>\n<p>&nbsp;<\/p>\n<p>You can either grant all privilege to the user or just grant him selected privilege on the database. To grant the user all the privileges, you can type the command line:<\/p>\n<pre>mysql&gt; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';<\/pre>\n<p>&nbsp;<\/p>\n<p>If you want to grant selected permissions, you must include the syntax for that particular permission in the GRANT command line. Examples of permissions you can grant to the user are CREATE (creation of new tables), DROP (delete tables), and UPDATE (update table rows). The command line for granting selected permissions should be as follows:<\/p>\n<pre>mysql&gt; GRANT type_of_permission ON database_name.table_name TO \u2018username\u2019@'localhost\u2019;<\/pre>\n<p>&nbsp;<\/p>\n<p>When you use the above syntex, make sure you put an asterisk in the place of the table_name.<\/p>\n<p>&nbsp;<\/p>\n<h5>Step Four: Removing Privilege and User from the Database<\/h5>\n<p>The command line for removing the privilege is the same as the granting the permission. However, you must use the word REVOKE instead of GRANT, for example:<\/p>\n<pre>mysql&gt; REVOKE type_of_permission ON database_name.table_name FROM \u2018username\u2019@\u2018localhost\u2019;<\/pre>\n<p>&nbsp;<\/p>\n<p>To find out what privilege a user has, you can type:<\/p>\n<pre>SHOW GRANTS username;<\/pre>\n<p>&nbsp;<\/p>\n<p>Deleting a user is just the same as deleting a database. When you want to delete a user, you must use the syntex DROP, for example:<\/p>\n<pre>DROP USER \u2018username\u2019@\u2018localhost\u2019;<\/pre>\n<p>&nbsp;<\/p>\n<h5>Conclusion<\/h5>\n<p>In conclusion, it is very simple to create a new user and grant him permission on a Maria DB MySQL. Even beginners can quickly pick up this knowledge and learn how to do this without any help from a professional programmer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a new user and allocating a set of permissions are the first steps you must take when you install a new application that operates based on MySQL\/MariaDB database engine. The guide provides tutorial on how to do this via the MySQL command line interface or other tools that allow the execution of SQL commands [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[706],"tags":[188,190,189],"class_list":["post-655","post","type-post","status-publish","format-standard","hentry","category-vps","tag-create-new-user-and-grant-permission-in-mysql-or-mariadb","tag-grant-permission-in-maridb-or-mysql","tag-how-to-create-mysql-and-mariadb-user-and-grant-permission"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Creating new user and grant permission in MySQL\/MariaDB - VPS - Web Hosting Blog - Dewlance<\/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:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating new user and grant permission in MySQL\/MariaDB - VPS - Web Hosting Blog - Dewlance\" \/>\n<meta property=\"og:description\" content=\"Creating a new user and allocating a set of permissions are the first steps you must take when you install a new application that operates based on MySQL\/MariaDB database engine. The guide provides tutorial on how to do this via the MySQL command line interface or other tools that allow the execution of SQL commands [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting Blog - Dewlance\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/dewlance.hosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-08T12:57:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-16T11:12:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif\" \/>\n<meta name=\"author\" content=\"K.S\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dewlance\" \/>\n<meta name=\"twitter:site\" content=\"@dewlance\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"K.S\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb\"},\"author\":{\"name\":\"K.S\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/#\/schema\/person\/0fe2f240cf5589599b50b9385ee53694\"},\"headline\":\"Creating new user and grant permission in MySQL\/MariaDB &#8211; VPS\",\"datePublished\":\"2018-06-08T12:57:07+00:00\",\"dateModified\":\"2022-08-16T11:12:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb\"},\"wordCount\":487,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif\",\"keywords\":[\"create new user and grant permission in mysql or mariadb\",\"grant permission in maridb or mysql\",\"how to create mysql and mariadb user and grant permission\"],\"articleSection\":[\"VPS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb\",\"url\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb\",\"name\":\"Creating new user and grant permission in MySQL\/MariaDB - VPS - Web Hosting Blog - Dewlance\",\"isPartOf\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif\",\"datePublished\":\"2018-06-08T12:57:07+00:00\",\"dateModified\":\"2022-08-16T11:12:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#primaryimage\",\"url\":\"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif\",\"contentUrl\":\"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.dewlance.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating new user and grant permission in MySQL\/MariaDB &#8211; VPS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/#website\",\"url\":\"https:\/\/www.dewlance.com\/blog\/\",\"name\":\"Web Hosting Blog - Dewlance\",\"description\":\"Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dewlance.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/#organization\",\"name\":\"Dewlance\",\"url\":\"https:\/\/www.dewlance.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.dewlance.com\/blog\/wp-content\/uploads\/2022\/08\/logo.png\",\"contentUrl\":\"https:\/\/www.dewlance.com\/blog\/wp-content\/uploads\/2022\/08\/logo.png\",\"width\":274,\"height\":89,\"caption\":\"Dewlance\"},\"image\":{\"@id\":\"https:\/\/www.dewlance.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/dewlance.hosting\/\",\"https:\/\/x.com\/dewlance\",\"https:\/\/www.youtube.com\/user\/dewlances\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dewlance.com\/blog\/#\/schema\/person\/0fe2f240cf5589599b50b9385ee53694\",\"name\":\"K.S\",\"url\":\"https:\/\/www.dewlance.com\/blog\/author\/dewlancevpsxen\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating new user and grant permission in MySQL\/MariaDB - VPS - Web Hosting Blog - Dewlance","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:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb","og_locale":"en_US","og_type":"article","og_title":"Creating new user and grant permission in MySQL\/MariaDB - VPS - Web Hosting Blog - Dewlance","og_description":"Creating a new user and allocating a set of permissions are the first steps you must take when you install a new application that operates based on MySQL\/MariaDB database engine. The guide provides tutorial on how to do this via the MySQL command line interface or other tools that allow the execution of SQL commands [&hellip;]","og_url":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb","og_site_name":"Web Hosting Blog - Dewlance","article_publisher":"https:\/\/www.facebook.com\/dewlance.hosting\/","article_published_time":"2018-06-08T12:57:07+00:00","article_modified_time":"2022-08-16T11:12:20+00:00","og_image":[{"url":"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif","type":"","width":"","height":""}],"author":"K.S","twitter_card":"summary_large_image","twitter_creator":"@dewlance","twitter_site":"@dewlance","twitter_misc":{"Written by":"K.S","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#article","isPartOf":{"@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb"},"author":{"name":"K.S","@id":"https:\/\/www.dewlance.com\/blog\/#\/schema\/person\/0fe2f240cf5589599b50b9385ee53694"},"headline":"Creating new user and grant permission in MySQL\/MariaDB &#8211; VPS","datePublished":"2018-06-08T12:57:07+00:00","dateModified":"2022-08-16T11:12:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb"},"wordCount":487,"commentCount":0,"publisher":{"@id":"https:\/\/www.dewlance.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#primaryimage"},"thumbnailUrl":"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif","keywords":["create new user and grant permission in mysql or mariadb","grant permission in maridb or mysql","how to create mysql and mariadb user and grant permission"],"articleSection":["VPS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb","url":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb","name":"Creating new user and grant permission in MySQL\/MariaDB - VPS - Web Hosting Blog - Dewlance","isPartOf":{"@id":"https:\/\/www.dewlance.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#primaryimage"},"image":{"@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#primaryimage"},"thumbnailUrl":"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif","datePublished":"2018-06-08T12:57:07+00:00","dateModified":"2022-08-16T11:12:20+00:00","breadcrumb":{"@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#primaryimage","url":"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif","contentUrl":"https:\/\/www.dewlance.com\/kb\/wp-content\/uploads\/2018\/06\/creating-new-user-and-grant-permission-in-Mysql-mardiadb-tutorial.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/www.dewlance.com\/blog\/creating-new-user-and-grant-permission-in-mysql-mariadb#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dewlance.com\/blog"},{"@type":"ListItem","position":2,"name":"Creating new user and grant permission in MySQL\/MariaDB &#8211; VPS"}]},{"@type":"WebSite","@id":"https:\/\/www.dewlance.com\/blog\/#website","url":"https:\/\/www.dewlance.com\/blog\/","name":"Web Hosting Blog - Dewlance","description":"Tutorials","publisher":{"@id":"https:\/\/www.dewlance.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dewlance.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.dewlance.com\/blog\/#organization","name":"Dewlance","url":"https:\/\/www.dewlance.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dewlance.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.dewlance.com\/blog\/wp-content\/uploads\/2022\/08\/logo.png","contentUrl":"https:\/\/www.dewlance.com\/blog\/wp-content\/uploads\/2022\/08\/logo.png","width":274,"height":89,"caption":"Dewlance"},"image":{"@id":"https:\/\/www.dewlance.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/dewlance.hosting\/","https:\/\/x.com\/dewlance","https:\/\/www.youtube.com\/user\/dewlances\/"]},{"@type":"Person","@id":"https:\/\/www.dewlance.com\/blog\/#\/schema\/person\/0fe2f240cf5589599b50b9385ee53694","name":"K.S","url":"https:\/\/www.dewlance.com\/blog\/author\/dewlancevpsxen"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/posts\/655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/comments?post=655"}],"version-history":[{"count":3,"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/posts\/655\/revisions"}],"predecessor-version":[{"id":1337,"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/posts\/655\/revisions\/1337"}],"wp:attachment":[{"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/media?parent=655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/categories?post=655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dewlance.com\/blog\/wp-json\/wp\/v2\/tags?post=655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}