{"id":680,"date":"2024-06-05T20:39:00","date_gmt":"2024-06-05T12:39:00","guid":{"rendered":"https:\/\/cn.raksmart.com\/blog\/host\/4271.html"},"modified":"2024-06-05T20:39:00","modified_gmt":"2024-06-05T12:39:00","slug":"mysql%e6%95%99%e7%a8%8b%ef%bc%881%ef%bc%89","status":"publish","type":"post","link":"https:\/\/cn.raksmart.com\/blog\/knowledge\/680.html","title":{"rendered":"Mysql\u6559\u7a0b\uff081\uff09"},"content":{"rendered":"<div class=\"entry-content e-content\" itemprop=\"description articleBody\">\n<p>\u4f5c\u4e3a\u63a8\u5e7f\u4eba\u5458\uff0c\u4e0d\u4ec5\u4ec5\u662f\u9700\u8981\u638c\u63e1\u63a8\u5e7f\u7684\u77e5\u8bc6\uff0c\u5173\u4e8e\u4e00\u4e9bweb\u670d\u52a1\u5668\u7684\u77e5\u8bc6\u4e5f\u662f\u9700\u8981\u638c\u63e1\u7684\uff0c\u4e0b\u9762\u5c31\u548cRaksmart<a rel=\"noreferrer noopener\" aria-label=\"\u7f8e\u56fd\u670d\u52a1\u5668\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"https:\/\/cn.raksmart.com\" target=\"_blank\"><strong>\u7f8e\u56fd\u670d\u52a1\u5668<\/strong><\/a>\u5c0f\u7f16\u770b\u770b\u4e00\u4e9b\u5173\u4e8e<a href=\"https:\/\/www.raksmart.com\/cps\/7921\" target=\"_blank\" rel=\"noopener\">Mysql<\/a>\u6570\u636e\u5e93\u7684\u77e5\u8bc6\u5427\u3002<\/p>\n<p class=\"has-text-color has-vivid-red-color\">\u767b\u5f55\u5230 <a href=\"https:\/\/www.raksmart.com\/cps\/7921\" target=\"_blank\" rel=\"noopener\">MySQL<\/a><\/p>\n<p>\u5f53 MySQL \u670d\u52a1\u5df2\u7ecf\u8fd0\u884c\u65f6, \u6211\u4eec\u53ef\u4ee5\u901a\u8fc7MySQL\u81ea\u5e26\u7684\u5ba2\u6237\u7aef\u5de5\u5177\u767b\u5f55\u5230MySQL\u6570\u636e\u5e93\u4e2d, \u9996\u5148\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26, \u8f93\u5165\u4ee5\u4e0b\u683c\u5f0f\u7684\u547d\u540d:<\/p>\n<p>mysql -h \u4e3b\u673a\u540d -u \u7528\u6237\u540d -p<\/p>\n<ul>\n<li>h : \u8be5\u547d\u4ee4\u7528\u4e8e\u6307\u5b9a\u5ba2\u6237\u7aef\u6240\u8981\u767b\u5f55\u7684MySQL\u4e3b\u673a\u540d, \u767b\u5f55\u5f53\u524d\u673a\u5668\u8be5\u53c2\u6570\u53ef\u4ee5\u7701\u7565;<\/li>\n<li>u : \u6240\u8981\u767b\u5f55\u7684\u7528\u6237\u540d;<\/li>\n<li>p : \u544a\u8bc9\u670d\u52a1\u5668\u5c06\u4f1a\u4f7f\u7528\u4e00\u4e2a\u5bc6\u7801\u6765\u767b\u5f55, \u5982\u679c\u6240\u8981\u767b\u5f55\u7684\u7528\u6237\u540d\u5bc6\u7801\u4e3a\u7a7a, \u53ef\u4ee5\u5ffd\u7565\u6b64\u9009\u9879\u3002 \u4ee5\u767b\u5f55\u521a\u521a\u5b89\u88c5\u5728\u672c\u673a\u7684MySQL\u6570\u636e\u5e93\u4e3a\u4f8b, \u5728\u547d\u4ee4\u884c\u4e0b\u8f93\u5165 mysql -u root -p \u6309\u56de\u8f66\u786e\u8ba4, \u5982\u679c\u5b89\u88c5\u6b63\u786e\u4e14MySQL\u6b63\u5728\u8fd0\u884c, \u4f1a\u5f97\u5230\u4ee5\u4e0b\u54cd\u5e94:<\/li>\n<\/ul>\n<p>Enter password:<\/p>\n<p>\u82e5\u5bc6\u7801\u5b58\u5728, \u8f93\u5165\u5bc6\u7801\u767b\u5f55, \u4e0d\u5b58\u5728\u5219\u76f4\u63a5\u6309\u56de\u8f66\u767b\u5f55, \u6309\u7167\u672c\u6587\u4e2d\u7684\u5b89\u88c5\u65b9\u6cd5, \u9ed8\u8ba4 root \u8d26\u53f7\u662f\u65e0\u5bc6\u7801\u7684\u3002\u767b\u5f55\u6210\u529f\u540e\u4f60\u5c06\u4f1a\u770b\u5230 Welecome to the MySQL monitor\u2026 \u7684\u63d0\u793a\u8bed\u3002<\/p>\n<p>\u7136\u540e\u547d\u4ee4\u63d0\u793a\u7b26\u4f1a\u4e00\u76f4\u4ee5 mysql&gt; \u52a0\u4e00\u4e2a\u95ea\u70c1\u7684\u5149\u6807\u7b49\u5f85\u547d\u4ee4\u7684\u8f93\u5165, \u8f93\u5165 exit \u6216 quit \u9000\u51fa\u767b\u5f55\u3002<\/p>\n<p class=\"has-text-color has-vivid-red-color\">\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93<\/p>\n<p>\u4f7f\u7528 create database \u8bed\u53e5\u53ef\u5b8c\u6210\u5bf9\u6570\u636e\u5e93\u7684\u521b\u5efa, \u521b\u5efa\u547d\u4ee4\u7684\u683c\u5f0f\u5982\u4e0b:<\/p>\n<p>create database \u6570\u636e\u5e93\u540d [\u5176\u4ed6\u9009\u9879];<\/p>\n<p>\u4f8b\u5982\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a samp_db \u7684\u6570\u636e\u5e93, \u5728\u547d\u4ee4\u884c\u4e0b\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4:<\/p>\n<p>create database<br \/>\nsamp_db character set gbk;<\/p>\n<p>\u4e3a\u4e86\u4fbf\u4e8e\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\u663e\u793a\u4e2d\u6587, \u5728\u521b\u5efa\u65f6\u901a\u8fc7 character set gbk \u5c06\u6570\u636e\u5e93\u5b57\u7b26\u7f16\u7801\u6307\u5b9a\u4e3a gbk\u3002\u521b\u5efa\u6210\u529f\u65f6\u4f1a\u5f97\u5230 Query OK, 1 row<br \/>\naffected(0.02 sec) \u7684\u54cd\u5e94\u3002<\/p>\n<p>\u6ce8\u610f: MySQL\u8bed\u53e5\u4ee5\u5206\u53f7(;)\u4f5c\u4e3a\u8bed\u53e5\u7684\u7ed3\u675f, \u82e5\u5728\u8bed\u53e5\u7ed3\u5c3e\u4e0d\u6dfb\u52a0\u5206\u53f7\u65f6, \u547d\u4ee4\u63d0\u793a\u7b26\u4f1a\u4ee5 -&gt; \u63d0\u793a\u4f60\u7ee7\u7eed\u8f93\u5165(\u6709\u4e2a\u522b\u7279\u4f8b, \u4f46\u52a0\u5206\u53f7\u662f\u4e00\u5b9a\u4e0d\u4f1a\u9519\u7684);<\/p>\n<p>\u63d0\u793a: \u53ef\u4ee5\u4f7f\u7528 show databases; \u547d\u4ee4\u67e5\u770b\u5df2\u7ecf\u521b\u5efa\u4e86\u54ea\u4e9b\u6570\u636e\u5e93\u3002<\/p>\n<p class=\"has-text-color has-vivid-red-color\">\u9009\u62e9\u6240\u8981\u64cd\u4f5c\u7684\u6570\u636e\u5e93<\/p>\n<p>\u8981\u5bf9\u4e00\u4e2a\u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c, \u5fc5\u987b\u5148\u9009\u62e9\u8be5\u6570\u636e\u5e93, \u5426\u5219\u4f1a\u63d0\u793a\u9519\u8bef:<\/p>\n<p>ERROR 1046(3D000): No database selected<\/p>\n<p>\u4e24\u79cd\u65b9\u5f0f\u5bf9\u6570\u636e\u5e93\u8fdb\u884c\u4f7f\u7528\u7684\u9009\u62e9:<\/p>\n<p>\u4e00: \u5728\u767b\u5f55\u6570\u636e\u5e93\u65f6\u6307\u5b9a, \u547d\u4ee4:\u00a0mysql<br \/>\n-D \u6240\u9009\u62e9\u7684\u6570\u636e\u5e93\u540d<br \/>\n-h \u4e3b\u673a\u540d<br \/>\n-u \u7528\u6237\u540d<br \/>\n-p<\/p>\n<p>\u4f8b\u5982\u767b\u5f55\u65f6\u9009\u62e9\u521a\u521a\u521b\u5efa\u7684\u6570\u636e\u5e93: mysql -D samp_db -u root -p<\/p>\n<p>\u4e8c: \u5728\u767b\u5f55\u540e\u4f7f\u7528 use \u8bed\u53e5\u6307\u5b9a, \u547d\u4ee4:use \u6570\u636e\u5e93\u540d;<\/p>\n<p>use \u8bed\u53e5\u53ef\u4ee5\u4e0d\u52a0\u5206\u53f7, \u6267\u884c use samp_db \u6765\u9009\u62e9\u521a\u521a\u521b\u5efa\u7684\u6570\u636e\u5e93, \u9009\u62e9\u6210\u529f\u540e\u4f1a\u63d0\u793a: Database changed<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u63a8\u5e7f\u4eba\u5458\uff0c\u4e0d\u4ec5\u4ec5\u662f\u9700\u8981\u638c\u63e1\u63a8\u5e7f\u7684\u77e5\u8bc6\uff0c\u5173\u4e8e\u4e00\u4e9bweb\u670d\u52a1\u5668\u7684\u77e5\u8bc6\u4e5f\u662f\u9700\u8981\u638c\u63e1\u7684\uff0c\u4e0b\u9762\u5c31\u548cRaks\u2026 <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[684],"class_list":["post-680","post","type-post","status-publish","format-standard","hentry","category-knowledge","tag-mysql"],"_links":{"self":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts\/680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/comments?post=680"}],"version-history":[{"count":0,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts\/680\/revisions"}],"wp:attachment":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/media?parent=680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/categories?post=680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/tags?post=680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}