{"id":575,"date":"2020-11-22T07:17:07","date_gmt":"2020-11-22T07:17:07","guid":{"rendered":"http:\/\/feellikelearning.com\/?p=575"},"modified":"2022-06-22T06:21:57","modified_gmt":"2022-06-22T06:21:57","slug":"cn-notes-of-using-mysql-on-ubuntu","status":"publish","type":"post","link":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/","title":{"rendered":"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu"},"content":{"rendered":"\n<p><strong>\u600e\u6837\u627eapt-get\u80fd\u5b89\u88c5\u7684mysql package?<\/strong><\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-code\"><code>apt-cache search mysql<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u4e3a\u4f8b\u5b50, \u5f88\u660e\u663e\u6211\u4eec\u9700\u8981server\u548cclient, \u7248\u672c\u4e3a\u793a\u8303<\/p>\n\n\n\n<p>mysql-server-5.7<br>mysql-client-5.7<\/p>\n\n\n\n<p><strong>\u600e\u6837\u5728ubuntu\u4e2d\u5b89\u88c5mysql?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install mysql-server-5.7\nsudo apt-get install mysql-client-5.7<\/code><\/pre>\n\n\n\n<p><strong>\u5b89\u88c5\u5b8c\u6210\u540e, \u600e\u6837\u542f\u52a8mysql server?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service mysql start<\/code><\/pre>\n\n\n\n<p>\u600e\u6837\u767b\u9646mysql<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mysql -u root\nmysql&gt;<\/code><\/pre>\n\n\n\n<p>mysql&gt; \u662fmysql client\u7684\u63d0\u793a\u7b26. \u770b\u5230\u8fd9\u4e2a\u5c31\u53ef\u4ee5\u8f93\u5165mysql\u7684\u547d\u4ee4\u4e86. <\/p>\n\n\n\n<p><strong>\u600e\u6837\u67e5\u770bmysql\u91cc\u9762\u73b0\u6709\u7684\u6570\u636e\u5e93 (database)?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| information_schema |\n| mysql              |\n| performance_schema |\n| sys                |\n+--------------------+<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a4\u4e2adatabases\u662fmysql\u81ea\u5e26\u7684.<\/p>\n\n\n\n<p><strong>\u4ec0\u4e48\u662fdatabase?<\/strong><\/p>\n\n\n\n<p>database\u5c31\u662ftables\u7684\u96c6\u5408. <\/p>\n\n\n\n<p>\u600e\u6837\u9009\u62e9\u4f7f\u7528\u54ea\u4e2adatabase?<\/p>\n\n\n\n<p>\u6bd4\u5982\u8bf4\u60f3\u7528database\u662fmydb<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql&gt; use mydb<\/code><\/pre>\n\n\n\n<p>\u600e\u6837\u770b\u67d0\u4e2adb\u4e0b\u9762\u6709\u4ec0\u4e48tables?<\/p>\n\n\n\n<p>\u7528\u4e86use mydb\u8f6c\u6362active\u7684db\u540e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql&gt; show tables;<\/code><\/pre>\n\n\n\n<p><strong>\u600e\u6837\u770b\u6bcf\u4e2adb\u7684size?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql&gt; SELECT table_schema AS \"Database\", SUM(data_length + index_length) \/ 1024 \/ 1024 AS \"Size (MB)\" FROM information_schema.TABLES GROUP BY table_schema;<\/code><\/pre>\n\n\n\n<p><strong>\u600e\u6837\u5907\u4efd\u67d0\u4e2adatabase?<\/strong><\/p>\n\n\n\n<p>\u7528mysqldump\u8fd9\u4e2a\u547d\u4ee4\u884c\u5de5\u5177<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo mysqldump -u &lt;user> -p --port=3306 --databases mydb > mydb.sql<\/code><\/pre>\n\n\n\n<p>\u4e00\u6b21\u5907\u4efd\u591a\u4e2adatabases\u4e5f\u53ef\u4ee5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo mysqldump  -u &lt;user> -p --port=3306 --databases db1 db2 db3 > mydb.sql<\/code><\/pre>\n\n\n\n<p>\u5907\u4efd\u51fa\u6765\u662f\u7528text\u65b9\u5f0f\u5199\u51fa\u6765\u7684sql, \u5305\u62ec\u91cc\u9762\u7684data. \u6bd4\u5982\u7528INSERT\u628a\u4e00\u6761\u4e00\u6761records\u52a0\u5230table\u91cc. \u4e0d\u77e5\u9053\u8fd9\u662f\u4e0d\u662f\u6807\u51c6\u7684\u5907\u4efd\u65b9\u5f0f&#8230; \u611f\u89c9\u5e94\u8be5\u6709\u66f4\u597d\u7684, \u4ee5\u540e\u7814\u7a76\u4e00\u4e0b\u518d\u8bf4<\/p>\n\n\n\n<p><strong>\u7528dump\u6062\u590ddatabase<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u &lt;user> -p &lt;database_name> &lt; &lt;dump_filename>.sql<\/code><\/pre>\n\n\n\n<p>\u53c2\u8003\u4e86<a href=\"https:\/\/dev.mysql.com\/doc\/mysql-backup-excerpt\/5.7\/en\/mysqldump-sql-format.html\">mysql\u5b98\u7f51<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u600e\u6837\u627eapt-get\u80fd\u5b89\u88c5\u7684mysql package?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.10 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu | Feel Like Learning<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu | Feel Like Learning\" \/>\n<meta property=\"og:description\" content=\"\u600e\u6837\u627eapt-get\u80fd\u5b89\u88c5\u7684mysql package?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant\" \/>\n<meta property=\"og:site_name\" content=\"Feel Like Learning\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-22T07:17:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-22T06:21:57+00:00\" \/>\n<meta name=\"author\" content=\"feellikelearning\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"feellikelearning\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant#article\",\"isPartOf\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant\"},\"author\":{\"name\":\"feellikelearning\",\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\"},\"headline\":\"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu\",\"datePublished\":\"2020-11-22T07:17:07+00:00\",\"dateModified\":\"2022-06-22T06:21:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant\"},\"wordCount\":55,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant\",\"url\":\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant\",\"name\":\"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu | Feel Like Learning\",\"isPartOf\":{\"@id\":\"https:\/\/feellikelearning.com\/#website\"},\"datePublished\":\"2020-11-22T07:17:07+00:00\",\"dateModified\":\"2022-06-22T06:21:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/feellikelearning.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/feellikelearning.com\/#website\",\"url\":\"https:\/\/feellikelearning.com\/\",\"name\":\"Feel Like Learning\",\"description\":\"\u7a0b\u5e8f\uff5c\u751f\u6d3b\uff5c\u5b66\u5230\u5c31\u662f\u8d5a\u5230\",\"publisher\":{\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/feellikelearning.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\",\"name\":\"feellikelearning\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/72a1e86e9dcb0332e88bd7d54fd36c28?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/72a1e86e9dcb0332e88bd7d54fd36c28?s=96&d=mm&r=g\",\"caption\":\"feellikelearning\"},\"logo\":{\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/feellikelearning.com\/index.php\/author\/feellikelearning\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu | Feel Like Learning","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant","og_locale":"en_US","og_type":"article","og_title":"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu | Feel Like Learning","og_description":"\u600e\u6837\u627eapt-get\u80fd\u5b89\u88c5\u7684mysql package?","og_url":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant","og_site_name":"Feel Like Learning","article_published_time":"2020-11-22T07:17:07+00:00","article_modified_time":"2022-06-22T06:21:57+00:00","author":"feellikelearning","twitter_card":"summary_large_image","twitter_misc":{"Written by":"feellikelearning","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant#article","isPartOf":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant"},"author":{"name":"feellikelearning","@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a"},"headline":"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu","datePublished":"2020-11-22T07:17:07+00:00","dateModified":"2022-06-22T06:21:57+00:00","mainEntityOfPage":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant"},"wordCount":55,"commentCount":0,"publisher":{"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant#respond"]}]},{"@type":"WebPage","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant","url":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant","name":"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu | Feel Like Learning","isPartOf":{"@id":"https:\/\/feellikelearning.com\/#website"},"datePublished":"2020-11-22T07:17:07+00:00","dateModified":"2022-06-22T06:21:57+00:00","breadcrumb":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/11\/22\/cn-notes-of-using-mysql-on-ubuntu\/?variant=zh-hant#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/feellikelearning.com\/"},{"@type":"ListItem","position":2,"name":"\u5728ubuntu\u4e2d\u4f7f\u7528mysql\u7b14\u8bb0 | Notes of using mysql on ubuntu"}]},{"@type":"WebSite","@id":"https:\/\/feellikelearning.com\/#website","url":"https:\/\/feellikelearning.com\/","name":"Feel Like Learning","description":"\u7a0b\u5e8f\uff5c\u751f\u6d3b\uff5c\u5b66\u5230\u5c31\u662f\u8d5a\u5230","publisher":{"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/feellikelearning.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a","name":"feellikelearning","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/72a1e86e9dcb0332e88bd7d54fd36c28?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/72a1e86e9dcb0332e88bd7d54fd36c28?s=96&d=mm&r=g","caption":"feellikelearning"},"logo":{"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/image\/"},"url":"https:\/\/feellikelearning.com\/index.php\/author\/feellikelearning\/"}]}},"_links":{"self":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts\/575"}],"collection":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/comments?post=575"}],"version-history":[{"count":21,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts\/575\/revisions"}],"predecessor-version":[{"id":1297,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts\/575\/revisions\/1297"}],"wp:attachment":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/media?parent=575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/categories?post=575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/tags?post=575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}