{"id":2392,"date":"2015-12-20T23:55:29","date_gmt":"2015-12-20T15:55:29","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2392"},"modified":"2015-12-20T23:55:29","modified_gmt":"2015-12-20T15:55:29","slug":"%e5%bd%bb%e5%ba%95%e5%88%a0%e9%99%a4mysql%e7%94%a8%e6%88%b7","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2392.html","title":{"rendered":"\u5f7b\u5e95\u5220\u9664MySQL\u7528\u6237"},"content":{"rendered":"<h6>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/h6>\n<ul>\n<li>mysql \u5220\u9664\u7528\u6237 delete drop<\/li>\n<li>linux mysql delete user<\/li>\n<li>mysql delete vs drop user<\/li>\n<\/ul>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/10560268\/difference-between-drop-user-and-deleting-a-row-from-the-mysql-user-table\">http:\/\/stackoverflow.com\/questions\/10560268\/difference-between-drop-user-and-deleting-a-row-from-the-mysql-user-table<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/8555154\/what-is-the-difference-between-drop-and-delete-for-tables\">http:\/\/stackoverflow.com\/questions\/8555154\/what-is-the-difference-between-drop-and-delete-for-tables<\/a><\/li>\n<li><a href=\"http:\/\/saadiya.blog.51cto.com\/2805761\/1109847\">http:\/\/saadiya.blog.51cto.com\/2805761\/1109847<\/a><\/li>\n<li><a href=\"http:\/\/www.liquidweb.com\/kb\/remove-a-mysql-user-on-linux-via-command-line\/\">http:\/\/www.liquidweb.com\/kb\/remove-a-mysql-user-on-linux-via-command-line\/<\/a><\/li>\n<li><a href=\"http:\/\/www.liquidweb.com\/kb\/remove-permissions-for-a-mysql-user-on-linux-via-command-line\/\">http:\/\/www.liquidweb.com\/kb\/remove-permissions-for-a-mysql-user-on-linux-via-command-line\/<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/blog.sae.sina.com.cn\/archives\/1912\">http:\/\/blog.sae.sina.com.cn\/archives\/1912<\/a><\/li>\n<li><a href=\"http:\/\/wolfchen.blog.51cto.com\/2211749\/1243990\">http:\/\/wolfchen.blog.51cto.com\/2211749\/1243990<\/a><\/li>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/privileges-provided.html\">https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/privileges-provided.html<\/a><\/li>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/grant.html\">https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/grant.html<\/a><\/li>\n<li><a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/drop-table.html\">http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/drop-table.html<\/a><\/li>\n<li><a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/delete.html\">http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/delete.html<\/a><\/li>\n<\/ul>\n<h5>\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<h6>\uff08\u65b9\u6cd5\u4e00\uff09drop user \u7528\u6237\u540d;<\/h6>\n<p>\u4f5c\u7528\uff1a\u5220\u9664\u5df2\u7ecf\u5b58\u5728\u7684\u7528\u6237\uff0c\u4f8b\u5982\u8981\u5220\u9664 abc \u8fd9\u4e2a\u7528\u6237\uff0c(drop user abc;)\u9ed8\u8ba4\u5220\u9664\u7684\u662f abc@&#8221;%&#8221; \u8fd9\u4e2a\u7528\u6237\uff0c\u5982\u679c\u8fd8\u6709\u5176\u4ed6\u7528\u6237\uff0c\u4f8b\u5982 abc@&#8221;localhost&#8221;, abc@&#8221;ip&#8221; \uff0c\u5219\u4e0d\u4f1a\u4e00\u8d77\u88ab\u5220\u9664\u3002\u5982\u679c\u53ea\u5b58\u5728\u4e00\u4e2a\u7528\u6237 abc@&#8221;localhost&#8221; \uff0c\u4f7f\u7528\u8bed\u53e5(drop user abc;)\u4f1a\u62a5\u9519\uff0c\u5e94\u8be5\u7528(drop user abc@&#8221;localhost&#8221;;)\u5982\u679c\u4e0d\u80fd\u786e\u5b9a\uff08\u7528\u6237\u540d@\u673a\u5668\u540d\uff09\u4e2d\u7684\u673a\u5668\u540d\uff0c\u53ef\u4ee5\u5728mysql\u4e2d\u7684user\u8868\u4e2d\u8fdb\u884c\u67e5\u627e\uff0cuser\u5217\u5bf9\u5e94\u7684\u662f\u7528\u6237\u540d\uff0chost\u5217\u5bf9\u5e94\u7684\u662f\u673a\u5668\u540d\u3002[\u5220\u9664\u8d26\u6237\u53ca\u6743\u9650]<\/p>\n<h6>\uff08\u65b9\u6cd5\u4e8c\uff09delete from user where user=&#8221;\u7528\u6237\u540d&#8221; and host=&#8221;\u673a\u5668\u540d&#8221;;<\/h6>\n<p>delete\u4e5f\u662f\u5220\u9664\u7528\u6237\u7684\u65b9\u6cd5\uff0c\u4f8b\u5982\u8981\u5220\u9664 abc@&#8221;localhost&#8221; \u7528\u6237\uff0c\u5219\u53ef\u4ee5(delete from mysql.user where user=&#8221;abc&#8221; and host=&#8221;localhost&#8221;;)[\u5220\u9664\u8d26\u6237]<\/p>\n<p>\u6ce8\uff1adrop\u5220\u9664\u6389\u7684\u7528\u6237\u4e0d\u4ec5\u5c06user\u8868\u4e2d\u7684\u6570\u636e\u5220\u9664\uff0c\u8fd8\u4f1a\u5220\u9664\u8bf8\u5982db\u548c\u5176\u4ed6\u6743\u9650\u8868\u7684\u5185\u5bb9\u3002\u800c\uff08\u65b9\u6cd5\u4e8c\uff09\u53ea\u662f\u5220\u9664\u4e86user\u8868\u7684\u5185\u5bb9\uff0c\u5176\u4ed6\u8868\u4e0d\u4f1a\u88ab\u5220\u9664\uff0c\u540e\u671f\u5982\u679c\u547d\u540d\u4e00\u4e2a\u548c\u5df2\u5220\u9664\u7528\u6237\u76f8\u540c\u7684\u540d\u5b57\uff0c\u6743\u9650\u5c31\u4f1a\u88ab\u7ee7\u627f\u3002<\/p>\n<pre class=\"lang:default decode:true\">root@localhost [(none)]&gt; status;\n--------------\nmysql  Ver 14.14 Distrib 5.6.25-73.1, for Linux (x86_64) using  6.3\n...\nServer version:        5.6.25-73.1 MySQL Community Server (GPL)\n\n\n&gt; select host,user,password from mysql.user;\n&gt; select host,user,password from mysql.user where user='';\n\n&gt; show grants for ''@localhost;\n&gt; drop user ''@localhost;\n&gt; flush privileges;\n\n&gt; select host,user,password from mysql.user;\n\n&gt; use mysql;\n&gt; update user set password=password('new-password-here') where user='root';\n\n&gt; select host,user,password from mysql.user;<\/pre>\n<ul>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/removing-users.html\">https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/removing-users.html<\/a><\/li>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/drop-user.html\">https:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/drop-user.html<\/a><\/li>\n<\/ul>\n<p>==<br \/>\nDROP is used to remove tables (and databases).<br \/>\nDELETE is used to delete rows from tables.<br \/>\n==<\/p>\n<pre class=\"lang:default decode:true \">\/* \u5220\u9664\u8868\u4e2d\u7684[\u6240\u6709]\u8bb0\u5f55 *\/\ndelete from mydb.mytable;\n\nTRUNCATE TABLE mydb.mytable;<\/pre>\n<pre class=\"lang:default decode:true\">\/* \u5728\u5220\u9664\u6240\u6709\u8bb0\u5f55\u540e\u91cd\u7f6e autoincrement \u7684\u503c *\/\nALTER TABLE `mytable` AUTO_INCREMENT = 1;\n\nSELECT MIN(`column`) FROM `mytable`;\nSELECT MAX(`column`) FROM `mytable`;<\/pre>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u641c\u7d22\u5173\u952e\u5b57\uff1a mysql \u5220\u9664\u7528\u6237 delete drop linux mysql delete user m [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,23,25],"tags":[16],"class_list":["post-2392","post","type-post","status-publish","format-standard","hentry","category-database","category-knowledgebase-2","category-security","tag-mysql"],"views":4588,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2392"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2392\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}