{"id":31663,"date":"2018-10-29T17:09:33","date_gmt":"2018-10-29T11:39:33","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=31663"},"modified":"2018-10-29T17:32:11","modified_gmt":"2018-10-29T12:02:11","slug":"create-mysql-user-on-linux-command-line","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/create-mysql-user-on-linux-command-line\/","title":{"rendered":"Create a MySQL User on Linux via Command Line"},"content":{"rendered":"<h3 id=\"pre-flight-check\"><span style=\"color: #800000;\">Pre-Flight Check<\/span><\/h3>\n<p>These directions square measure meant for making a <a href=\"https:\/\/www.wikitechy.com\/angularjs\/angularjs-update-using-php-mysql\" target=\"_blank\" rel=\"noopener\">MySQL<\/a> user on <a href=\"https:\/\/www.wikitechy.com\/tutorials\/linux\/how-to-find-patterns-across-multiple-lines-using-grep\" target=\"_blank\" rel=\"noopener\">Linux<\/a> via the statement.<\/p>\n<p>I\u2019ll be engaging from a Liquid net Core Managed <strong>CentOS<\/strong> half-dozen.5 server, and I\u2019ll be logged in as root.<\/p>\n<h2 id=\"login-to-mysql\"><span style=\"color: #ff0000;\">Login to MySQL<\/span><\/h2>\n<p>First we\u2019ll login to the MySQL server from the <a href=\"https:\/\/www.wikitechy.com\/technology\/10-command-prompt-tricks\/\" target=\"_blank\" rel=\"noopener\">command line<\/a> with the following command:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MySQL<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">mysql -u root -p<\/code><\/pre> <\/div>\n<p>In this case, I\u2019ve given the user root with the <strong>-u flag<\/strong>, thus used the <strong>-p flag<\/strong> so MySQL prompts for a positive identification. Enter your current positive identification to finish the login.<\/p>\n<p>If you would like to vary your root (or any other) positive identification within the information, then follow this tutorial on dynamical a positive identification for MySQL via the command.<\/p>\n<p>You should currently be at a MySQL prompt that appears terribly just like this:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MySQL<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">mysql&gt;<\/code><\/pre> <\/div>\n<h2 id=\"create-mysql-user\"><span style=\"color: #ff0000;\">Create MySQL User<\/span><\/h2>\n<p>We\u2019ll create a user with the name <strong>testuser<\/strong> , and the password <strong>test123test!.<\/strong><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MySQL<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">CREATE USER &#039;testuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123test!&#039;;<\/code><\/pre> <\/div>\n<p>That\u2019s it, congratulations! In just one command you\u2019ve created your first MySQL user. However, this user won\u2019t be able to do anything with <a href=\"https:\/\/www.wikitechy.com\/tutorials\/sql\/insert-into-select\" target=\"_blank\" rel=\"noopener\">MySQL<\/a> until they are granted additional privileges. In fact, they won\u2019t even be able to login without additional permissions.<\/p>\n<p>To give the new user proper permissions, work through our tutorial on granting permissions to MySQL user\u2019s via the command line.<\/p>\n<h2 id=\"view-a-list-of-mysql-users\"><span style=\"color: #ff0000;\">View a List of MySQL Users<\/span><\/h2>\n<p>Viewing a full list of MySQL users, including the host they\u2019re associated with, can be done with the following select statement:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MySQL<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">SELECT User,Host FROM mysql.user;<\/code><\/pre> <\/div>\n<h3 id=\"output\"><span style=\"color: #003300;\"><strong>Output:<\/strong><\/span><\/h3>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\" wp-image-31667 alignleft\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2018\/10\/sql-users.png\" alt=\"sql-users\" width=\"485\" height=\"288\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2018\/10\/sql-users.png 341w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2018\/10\/sql-users-300x179.png 300w\" sizes=\"(max-width: 485px) 100vw, 485px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pre-Flight Check These directions square measure meant for making a MySQL user on Linux via the statement. I\u2019ll be engaging from a Liquid net Core Managed CentOS half-dozen.5 server, and I\u2019ll be logged in as root. Login to MySQL First we\u2019ll login to the MySQL server from the command line with the following command: In [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1205,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1699,27],"tags":[85600,85601,85605,2108,85597,85599,85609,85602,85608,85606,85598,85603,85604,85607],"class_list":["post-31663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-mysql","tag-create-user-mysql","tag-mysql-5-7-create-user","tag-mysql-add-user","tag-mysql-create-database","tag-mysql-create-remote-user","tag-mysql-create-user-with-password","tag-mysql-grant-all-privileges-identified-by-password","tag-mysql-grant-all-privileges-to-root","tag-mysql-grant-all-privileges-to-user-from-any-host","tag-mysql-grant-usage","tag-mysql-grant-user-access-to-database","tag-mysql-list-users","tag-mysql-list-users-and-permissions","tag-mysql-show-grants"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/31663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=31663"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/31663\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media\/1205"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=31663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=31663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=31663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}