{"id":279,"date":"2010-03-17T10:44:44","date_gmt":"2010-03-17T10:44:44","guid":{"rendered":""},"modified":"2010-03-17T10:44:44","modified_gmt":"2010-03-17T10:44:44","slug":"279","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=279","title":{"rendered":"MySQL\u6570\u636e\u5e93\u5e38\u7528\u547d\u4ee4 \u8d85\u7ea7\u5b9e\u7528\u7248\u5206\u4eab"},"content":{"rendered":"<p>1\u3001MySQL\u5e38\u7528\u547d\u4ee4 <\/p>\n<p>create database name; \u521b\u5efa\u6570\u636e\u5e93 <\/p>\n<p>use databasename; \u9009\u62e9\u6570\u636e\u5e93 <\/p>\n<p>drop database name \u76f4\u63a5\u5220\u9664\u6570\u636e\u5e93\uff0c\u4e0d\u63d0\u9192 <\/p>\n<p>show tables; \u663e\u793a\u8868 <\/p>\n<p>describe tablename; \u8868\u7684\u8be6\u7ec6\u63cf\u8ff0 <\/p>\n<p>select \u4e2d\u52a0\u4e0adistinct\u53bb\u9664\u91cd\u590d\u5b57\u6bb5 <\/p>\n<p>mysqladmin drop databasename \u5220\u9664\u6570\u636e\u5e93\u524d\uff0c\u6709\u63d0\u793a\u3002 <\/p>\n<p>\u663e\u793a\u5f53\u524dmysql\u7248\u672c\u548c\u5f53\u524d\u65e5\u671f <\/p>\n<p>select version(),current_date; <\/p>\n<p>2\u3001\u4fee\u6539mysql\u4e2droot\u7684\u5bc6\u7801\uff1a <\/p>\n<p>shell&gt;mysql -u root -p <\/p>\n<p>mysql&gt; update user set password=password(\u201dxueok654123\u2033) where user=\u2019root\u2019; <\/p>\n<p>mysql&gt; flush privileges \/\/\u5237\u65b0\u6570\u636e\u5e93 <\/p>\n<p>mysql&gt;use dbname\uff1b \u6253\u5f00\u6570\u636e\u5e93\uff1a <\/p>\n<p>mysql&gt;show databases; \u663e\u793a\u6240\u6709\u6570\u636e\u5e93 <\/p>\n<p>mysql&gt;show tables; \u663e\u793a\u6570\u636e\u5e93mysql\u4e2d\u6240\u6709\u7684\u8868\uff1a\u5148use mysql\uff1b\u7136\u540e <\/p>\n<p>mysql&gt;describe user; \u663e\u793a\u8868mysql\u6570\u636e\u5e93\u4e2duser\u8868\u7684\u5217\u4fe1\u606f\uff09\uff1b <\/p>\n<p>3\u3001grant <\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u53ef\u4ee5\u4ece\u4efb\u4f55\u5730\u65b9\u8fde\u63a5\u670d\u52a1\u5668\u7684\u4e00\u4e2a\u5b8c\u5168\u7684\u8d85\u7ea7\u7528\u6237\uff0c\u4f46\u662f\u5fc5\u987b\u4f7f\u7528\u4e00\u4e2a\u53e3\u4ee4something\u505a\u8fd9\u4e2a <\/p>\n<p>mysql&gt; grant all privileges on *.* to identified by \u2019something\u2019 with <\/p>\n<p>\u589e\u52a0\u65b0\u7528\u6237 <\/p>\n<p>\u683c\u5f0f\uff1agrant select on \u6570\u636e\u5e93.* to \u7528\u6237\u540d@\u767b\u5f55\u4e3b\u673a identified by \u201c\u5bc6\u7801\u201d <\/p>\n<p>GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY \u2019something\u2019 WITH GRANT OPTION; <\/p>\n<p>GRANT ALL PRIVILEGES ON *.* TO \u201d IDENTIFIED BY \u2019something\u2019 WITH GRANT OPTION; <\/p>\n<p>\u5220\u9664\u6388\u6743\uff1a <\/p>\n<p>mysql&gt; revoke all privileges on *.* from \u201d; <\/p>\n<p>mysql&gt; delete from user where user=\u201droot\u201d and host=\u201d%\u201d; <\/p>\n<p>mysql&gt; flush privileges; <\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u7528\u6237custom\u5728\u7279\u5b9a\u5ba2\u6237\u7aefit363.com\u767b\u5f55\uff0c\u53ef\u8bbf\u95ee\u7279\u5b9a\u6570\u636e\u5e93fangchandb <\/p>\n<p>mysql &gt;grant select, insert, update, delete, create,drop on fangchandb.* to custom@ it363.com identified by \u2018 passwd\u2019 <\/p>\n<p>\u91cd\u547d\u540d\u8868: <\/p>\n<p>mysql &gt; alter table t1 rename t2; <\/p>\n<p>4\u3001mysqldump <\/p>\n<p>\u5907\u4efd\u6570\u636e\u5e93 <\/p>\n<p>shell&gt; mysqldump -h host -u root -p dbname &gt;dbname_backup.sql <\/p>\n<p>\u6062\u590d\u6570\u636e\u5e93 <\/p>\n<p>shell&gt; mysqladmin -h myhost -u root -p create dbname <\/p>\n<p>shell&gt; mysqldump -h host -u root -p dbname &lt; dbname_backup.sql <\/p>\n<p>\u5982\u679c\u53ea\u60f3\u5378\u51fa\u5efa\u8868\u6307\u4ee4\uff0c\u5219\u547d\u4ee4\u5982\u4e0b\uff1a <\/p>\n<p>shell&gt; mysqladmin -u root -p -d databasename &gt; a.sql <\/p>\n<p>\u5982\u679c\u53ea\u60f3\u5378\u51fa\u63d2\u5165\u6570\u636e\u7684sql\u547d\u4ee4\uff0c\u800c\u4e0d\u9700\u8981\u5efa\u8868\u547d\u4ee4\uff0c\u5219\u547d\u4ee4\u5982\u4e0b\uff1a <\/p>\n<p>shell&gt; mysqladmin -u root -p -t databasename &gt; a.sql <\/p>\n<p>\u90a3\u4e48\u5982\u679c\u6211\u53ea\u60f3\u8981\u6570\u636e\uff0c\u800c\u4e0d\u60f3\u8981\u4ec0\u4e48sql\u547d\u4ee4\u65f6\uff0c\u5e94\u8be5\u5982\u4f55\u64cd\u4f5c\u5462\uff1f <\/p>\n<p>\u3000\u3000 mysqldump -T.\/ phptest driver <\/p>\n<p>\u5176\u4e2d\uff0c\u53ea\u6709\u6307\u5b9a\u4e86-T\u53c2\u6570\u624d\u53ef\u4ee5\u5378\u51fa\u7eaf\u6587\u672c\u6587\u4ef6\uff0c\u8868\u793a\u5378\u51fa\u6570\u636e\u7684\u76ee\u5f55\uff0c.\/\u8868\u793a\u5f53\u524d\u76ee\u5f55\uff0c\u5373\u4e0emysqldump\u540c\u4e00\u76ee\u5f55\u3002\u5982\u679c\u4e0d\u6307\u5b9adriver \u8868\uff0c\u5219\u5c06\u5378\u51fa\u6574\u4e2a\u6570\u636e\u5e93\u7684\u6570\u636e\u3002\u6bcf\u4e2a\u8868\u4f1a\u751f\u6210\u4e24\u4e2a\u6587\u4ef6\uff0c\u4e00\u4e2a\u4e3a.sql\u6587\u4ef6\uff0c\u5305\u542b\u5efa\u8868\u6267\u884c\u3002\u53e6\u4e00\u4e2a\u4e3a.txt\u6587\u4ef6\uff0c\u53ea\u5305\u542b\u6570\u636e\uff0c\u4e14\u6ca1\u6709sql\u6307\u4ee4\u3002 <\/p>\n<p>5\u3001\u53ef\u5c06\u67e5\u8be2\u5b58\u50a8\u5728\u4e00\u4e2a\u6587\u4ef6\u4e2d\u5e76\u544a\u8bc9mysql\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u67e5\u8be2\u800c\u4e0d\u662f\u7b49\u5f85\u952e\u76d8\u8f93\u5165\u3002\u53ef\u5229\u7528\u5916\u58f3\u7a0b\u5e8f\u952e\u5165\u91cd\u5b9a\u5411\u5b9e\u7528\u7a0b\u5e8f\u6765\u5b8c\u6210\u8fd9\u9879\u5de5\u4f5c\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5728\u6587\u4ef6my_file.sql \u4e2d\u5b58\u653e\u6709\u67e5 <\/p>\n<p>\u8be2\uff0c\u53ef\u5982\u4e0b\u6267\u884c\u8fd9\u4e9b\u67e5\u8be2\uff1a <\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u5c06\u5efa\u8868\u8bed\u53e5\u63d0\u524d\u5199\u5728sql.txt\u4e2d: <\/p>\n<p>mysql &gt; mysql -h myhost -u root -p database &lt; sql.txt <\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001MySQL\u5e38\u7528\u547d\u4ee4 create database name; &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-279","post","type-post","status-publish","format-standard","hentry","category-DB"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=279"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/279\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}