{"id":3263,"date":"2018-03-27T15:01:57","date_gmt":"2018-03-27T07:01:57","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=3263"},"modified":"2018-03-27T15:15:14","modified_gmt":"2018-03-27T07:15:14","slug":"mysql%e5%91%bd%e4%bb%a4%e8%a1%8c%e4%b8%8b18%e4%b8%aa%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/jishu\/shujuku\/mysql%e5%91%bd%e4%bb%a4%e8%a1%8c%e4%b8%8b18%e4%b8%aa%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4\/","title":{"rendered":"MySQL\u547d\u4ee4\u884c\u4e0b18\u4e2a\u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"<p>\u5728\u65e5\u5e38\u7684\u7f51\u7ad9\u7ef4\u62a4\u548c\u7ba1\u7406\u4e2d\uff0c\u4f1a\u7528\u5230\u975e\u5e38\u591a\u7684SQL\u8bed\u53e5\uff0c<br \/>\n\u719f\u7ec3\u4f7f\u7528\u5bf9\u7f51\u7ad9\u7ba1\u7406\u6709\u5f88\u591a\u597d\u5904\uff0c\u5c24\u5176\u662f\u7ad9\u7fa4\u7ba1\u7406\u7684\u65f6\u5019\u3002<\/p>\n<p>\u4e0b\u9762\u5217\u4e00\u4e9b\u5e38\u7528\u7684\u547d\u4ee4\u505a\u5907\u8bb0\u3002<\/p>\n<p><strong>1\u3001\u663e\u793a\u6570\u636e\u5e93\u00a0<\/strong><br \/>\nshow databases<br \/>\n\u663e\u793a\u8868<br \/>\nshow tables;<\/p>\n<p><strong>\u00a02\u3001\u521b\u5efa\u7528\u6237\u00a0<\/strong><br \/>\n\u521b\u5efaroot\u7528\u6237\u5bc6\u7801\u4e3a123<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">use mysql; \r\ngrant all on *.* to root@'%' identified by '123' with grant option; \r\ncommit;<\/pre>\n<\/div>\n<p><strong>\u00a03\u3001\u4fee\u6539\u5bc6\u7801\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">grant all on *.* to xing@'localhost' identified by '123456' with grant option; \r\nupdate user set password = password('newpwd') where user = 'xing' and host='localhost'; \r\nflush privileges;<\/pre>\n<\/div>\n<p><strong>\u00a04\u3001\u521b\u5efa\u6570\u636e\u5e93testdb\uff1a<br \/>\n<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">create database testdb;<\/pre>\n<\/div>\n<p><strong>\u00a05\u3001\u9884\u9632\u6027\u521b\u5efa\u6570\u636e\u5e93\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">create database if not testdb;<\/pre>\n<\/div>\n<p><strong>\u00a06\u3001\u521b\u5efa\u8868\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">use testdb; \r\ncreate table table1( \r\nusername varchar(12), \r\npassword varchar(20));<\/pre>\n<\/div>\n<p><strong>\u00a07\u3001\u9884\u9632\u6027\u521b\u5efa\u8868aaa\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">create table if not exists aaa(ss varchar(20));<\/pre>\n<\/div>\n<p><strong>\u00a08\u3001\u67e5\u770b\u8868\u7ed3\u6784\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">describe table1;<\/pre>\n<\/div>\n<p><strong>\u00a09\u3001\u63d2\u5165\u6570\u636e\u5230\u8868table1\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">insert into table1(username,password) values \r\n('leizhimin','lavasoft'), \r\n('hellokitty','hahhahah'); \r\ncommit;<\/pre>\n<\/div>\n<p><strong>\u00a010\u3001\u67e5\u8be2\u8868table1\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">select * from table1;<\/pre>\n<\/div>\n<p><strong>\u00a011\u3001\u66f4\u6539\u6570\u636e\uff1a<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">update table1 set password='hehe' where username='hellokitty'; \r\ncommit;<\/pre>\n<\/div>\n<p><strong>\u00a012\u3001\u5220\u9664\u6570\u636e\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">delete from table1 where username='hellokitty'; \r\ncommit;<\/pre>\n<\/div>\n<p><strong>13\u3001\u7ed9\u8868\u6dfb\u52a0\u4e00\u5217\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">alter table table1 add column( \r\n sex varchar(2) comment '\u6027\u522b', \r\n age date not null comment '\u5e74\u9f84' \r\n); \r\ncommit;<\/pre>\n<\/div>\n<p><strong>14\u3001\u4fee\u6539\u8868\u7ed3\u6784<\/strong><\/p>\n<p>\u4ece\u67e5\u8be2\u521b\u5efa\u4e00\u4e2a\u8868table1\uff1a<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">create table tmp as \r\nselect * from table1;<\/pre>\n<\/div>\n<p><strong>15\u3001\u5220\u9664\u8868table1\uff1a\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">drop table if exists table1; \r\ndrop table if exists tmp;<\/pre>\n<\/div>\n<p><strong>16\u3001\u5907\u4efd\u6570\u636e\u5e93testdb\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">mysqldump -h 192.168.3.143 -u root -p pwd -x --default-character-set=gbk &gt;C:\\testdb.sql<\/pre>\n<\/div>\n<p><strong>17\u3001\u5220\u9664\u6570\u636e\u5e93testdb\u00a0<\/strong><\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">drop database testdb;<\/pre>\n<\/div>\n<p><strong>18\u3001\u6062\u590dtestdb\u6570\u636e\u5e93\u00a0<\/strong><br \/>\n\u9996\u5148\u5148\u5efa\u7acbtestdb\u6570\u636e\u5e93\uff0c\u7136\u540e\u7528\u4e0b\u9762\u547d\u4ee4\u8fdb\u884c\u672c\u5730\u6062\u590d<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">mysql -u root -pleizhimin testdb &lt;C:\\testdb.sql<\/pre>\n<\/div>\n<p>\u8fd918\u4e2aMYSQL\u547d\u4ee4\u90fd\u662f\u7ba1\u7406\u5458\u5728\u65e5\u5e38\u7ef4\u62a4\u4e2d\u7ecf\u5e38\u4f1a\u7528\u5230\u7684\uff0c\u719f\u7ec3\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\u4f1a\u4f7f\u4f60\u7684\u5de5\u4f5c\u975e\u5e38\u8f7b\u677e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u65e5\u5e38\u7684\u7f51\u7ad9\u7ef4\u62a4\u548c\u7ba1\u7406\u4e2d\uff0c\u4f1a\u7528\u5230\u975e\u5e38\u591a\u7684SQL\u8bed\u53e5\uff0c \u719f\u7ec3\u4f7f\u7528\u5bf9\u7f51\u7ad9\u7ba1\u7406\u6709\u5f88\u591a\u597d\u5904\uff0c\u5c24\u5176\u662f\u7ad9\u7fa4\u7ba1\u7406\u7684\u65f6\u5019\u3002 \u4e0b &#8230; <a title=\"MySQL\u547d\u4ee4\u884c\u4e0b18\u4e2a\u5e38\u7528\u547d\u4ee4\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/jishu\/shujuku\/mysql%e5%91%bd%e4%bb%a4%e8%a1%8c%e4%b8%8b18%e4%b8%aa%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4\/\" aria-label=\"\u9605\u8bfb MySQL\u547d\u4ee4\u884c\u4e0b18\u4e2a\u5e38\u7528\u547d\u4ee4\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[],"class_list":["post-3263","post","type-post","status-publish","format-standard","hentry","category-shujuku"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=3263"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3263\/revisions"}],"predecessor-version":[{"id":3264,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3263\/revisions\/3264"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=3263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=3263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=3263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}