{"id":31771,"date":"2018-10-31T12:51:51","date_gmt":"2018-10-31T07:21:51","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=31771"},"modified":"2018-10-31T12:53:56","modified_gmt":"2018-10-31T07:23:56","slug":"grant-permissions-to-mysql-user-on-linux-command","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/grant-permissions-to-mysql-user-on-linux-command\/","title":{"rendered":"Grant Permissions to a MySQL User on Linux via Command Line"},"content":{"rendered":"<h3 id=\"pre-flight-check\"><span style=\"color: #800000;\"><strong>Pre-Flight Check<\/strong><\/span><\/h3>\n<p>These directions square measure meant for granting a MySQL user permissions on LINUX system via the instruction<\/p>\n<p>I\u2019ll be engaging from a <strong>Liquid internet Core<\/strong> Managed <strong>CentOS six.5<\/strong> server, and I\u2019ll be logged in as root.<\/p>\n<h3 id=\"login-to-mysql\"><span style=\"color: #333399;\">Login to MySQL<\/span><\/h3>\n<p>First we\u2019ll login to the MySQL server from the instruction with the following command:<\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dmysql%20-u%20root%20-p\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p>In this case, I\u2019ve mere the user root with the <strong>-u flag<\/strong>, so used the<strong> -p flag<\/strong> so MySQL prompts for a parole. Enter your current parole to finish the login.<\/p>\n<p>If you would like to alter your root (or any other) parole within the info, then follow this tutorial on ever-changing a parole for MySQL via the <a href=\"https:\/\/www.wikitechy.com\/technology\/force-a-delete\/\" target=\"_blank\" rel=\"noopener\">command<\/a><\/p>\n<p>You should currently be at a MySQL prompt that appears terribly almost like this:<\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dmysql%3E\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p>If you haven\u2019t nonetheless created a MySQL user, please visit our tutorial on making a <a href=\"https:\/\/www.wikitechy.com\/technology\/create-mysql-user-on-linux-command-line\/\" target=\"_blank\" rel=\"noopener\">MySQL user<\/a>.<\/p>\n<h3 id=\"grant-permissions-to-mysql-user\"><span style=\"color: #003366;\">Grant Permissions to MySQL User:<\/span><\/h3>\n<p>The basic syntax for granting permissions is as follows:<\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dGRANT%20permission%20ON%20database.table%20TO%20\u2019user\u2019%40\u2019localhost\u2019%3B\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p><span style=\"color: #3366ff;\"><strong>Here is a brief list of usually used permissions :<\/strong><\/span><\/p>\n<p><span style=\"color: #008080;\"><strong>ALL<\/strong> <\/span>\u2013 enable complete access to a particular info. If a info isn\u2019t such, then enable complete access to the whole lot of MySQL.<\/p>\n<p><span style=\"color: #008080;\"><strong>CREATE<\/strong> <\/span>\u2013 enable a user to make databases and tables.<\/p>\n<p><span style=\"color: #008080;\"><strong>DELETE <\/strong><\/span>\u2013 enable a user to delete rows from a table.<\/p>\n<p><span style=\"color: #008080;\"><strong>DROP<\/strong> <\/span>\u2013 enable a user to drop databases and tables.<\/p>\n<p><span style=\"color: #008080;\"><strong>EXECUTE<\/strong><\/span> \u2013 enable a user to execute hold on routines.<\/p>\n<p><span style=\"color: #008080;\"><strong>GRANT <\/strong><\/span>possibility \u2013 enable a user to grant or take away another user\u2019s privileges.<\/p>\n<p><span style=\"color: #008080;\"><strong>INSERT<\/strong><\/span> \u2013 enable a user to insert rows from a table.<\/p>\n<p><span style=\"color: #008080;\"><strong>SELECT<\/strong> <\/span>\u2013 enable a user to pick knowledge from a info.<\/p>\n<p><span style=\"color: #008080;\"><strong>SHOW DATABASES<\/strong><\/span>\u2013 enable a user to look at an inventory of all databases.<\/p>\n<p><span style=\"color: #008080;\"><strong>UPDATE <\/strong><\/span>\u2013 enable a user to update rows in a table.<\/p>\n<p>\u00a0<\/p>\n<p><span style=\"color: #333300;\"><strong>Example #1:<\/strong><\/span> To grant produce permissions for all databases * and every one tables * to the user we created within the previous tutorial, testuser , use the following command:<\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dGRANT%20CREATE%20ON%20*.*%20TO%20\u2019testuser\u2019%40\u2019localhost\u2019%3B\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p>Using an asterisk (*) within the place of the information or table is a very valid possibility, and implies all <a href=\"https:\/\/www.wikitechy.com\/tutorials\/laravel\/laravel-database\" target=\"_blank\" rel=\"noopener\">databases<\/a> or all tables.<\/p>\n<p><span style=\"color: #333300;\"><strong>Example #2<\/strong>:<\/span> To grant testuser the flexibility to <a href=\"https:\/\/www.wikitechy.com\/tutorials\/sql\/drop-table\" target=\"_blank\" rel=\"noopener\">drop tables<\/a> within the specific information, tutorial_database , use the DROP permission:<\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dGRANT%20DROP%20ON%20tutorial_database.*%20TO%20\u2019testuser\u2019%40\u2019localhost\u2019%3B\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p>When finished making your permission changes, it\u2019s good practice to reload all the privileges with the flush command!<\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dFLUSH%20PRIVILEGES%3B\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h3 id=\"view-grants-for-mysql-user\"><span style=\"color: #003300;\">View Grants for MySQL User:<\/span><\/h3>\n<p>After you\u2019ve granted permissions to a MySQL user you\u2019ll probably want to double check them. Use the following command to check the grants for testuser:<\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dSHOW%20GRANTS%20FOR%20\u2019testuser\u2019%40\u2019localhost\u2019%3B\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h3 id=\"output\"><span style=\"color: #008000;\">Output:<\/span><\/h3>\n[pastacode lang=\u201dless\u201d manual=\u201d%2B\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014%2B%0A%7C%20Grants%20for%20testuser%40localhost%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7C%0A%2B\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014%2B%0A%7C%20GRANT%20ALL%20PRIVILEGES%20ON%20*.*%20TO%20\u2019testuser\u2019%40\u2019localhost\u2019%20WITH%20GRANT%20OPTION%20%7C%0A%2B\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014%2B\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pre-Flight Check These directions square measure meant for granting a MySQL user permissions on LINUX system via the instruction I\u2019ll be engaging from a Liquid internet Core Managed CentOS six.5 server, and I\u2019ll be logged in as root. Login to MySQL First we\u2019ll login to the MySQL server from the instruction with the following command: [&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,85597,85694,85609,85602,85608,85695,85606,85696,85598,85697,85698,85699,85700,85701,85702,534,85607,85703,85704,535,85705,85706,537],"class_list":["post-31771","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-mysql","tag-create-user-mysql","tag-mysql-create-remote-user","tag-mysql-create-user","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-super","tag-mysql-grant-usage","tag-mysql-grant-usage-identified-by-password","tag-mysql-grant-user-access-to-database","tag-mysql-grants","tag-mysql-privileges","tag-mysql-privileges-list","tag-mysql-remove-grants","tag-mysql-revoke-privileges","tag-mysql-show-all-users","tag-mysql-show-current-user","tag-mysql-show-grants","tag-mysql-show-grants-on-table","tag-mysql-show-grants-wildcard","tag-mysql-show-user-password","tag-mysql-show-users-permissions","tag-mysql-with-grant-option","tag-mysql-user-table"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/31771","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=31771"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/31771\/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=31771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=31771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=31771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}