{"id":1544,"date":"2022-03-01T13:53:36","date_gmt":"2022-03-01T05:53:36","guid":{"rendered":"https:\/\/dasmz.com\/?p=1544"},"modified":"2022-03-01T16:06:43","modified_gmt":"2022-03-01T08:06:43","slug":"%e7%b3%bb%e7%bb%9f%e7%8e%af%e5%a2%83ubuntu-20-04-lts%ef%bc%8c%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85mysql-2022-03-01","status":"publish","type":"post","link":"https:\/\/dasmz.com\/?p=1544","title":{"rendered":"\u7cfb\u7edf\u73af\u5883Ubuntu 20.04\u6216\u8005Debian 10\uff0c\u5b89\u88c5MySQL 8\u6570\u636e\u5e93 2022-03-01"},"content":{"rendered":"\n<p><strong>\u6bb5\u843d1\u3001\u9700\u6c42<\/strong><\/p>\n\n\n\n<p>\u5728Ubuntu 20.04 LTS\u73af\u5883\u4e0a\uff0c\u7f16\u8bd1\u5b89\u88c5MySQL\u6570\u636e\u5e93<\/p>\n\n\n\n<p><strong>\u6bb5\u843d2\u3001\u90e8\u7f72\u5b9e\u65bd<\/strong><\/p>\n\n\n\n<p>\u66f4\u65b0\u5305\u7d22\u5f15<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt-get update<\/pre>\n\n\n\n<p>\u5b89\u88c5MySQL Server<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install mysql-server<\/pre>\n\n\n\n<p><em>\u5b89\u88c5\u7684\u4e00\u4e9b\u5305\u4fe1\u606f\u5982\u4e0b<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>The following NEW packages will be installed:\n  libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7\n  libevent-pthreads-2.1-7 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl\n  libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl\n  liblwp-mediatypes-perl libmecab2 libtimedate-perl liburi-perl mecab-ipadic\n  mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0\n  mysql-common mysql-server mysql-server-8.0 mysql-server-core-8.0\n0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 31.4 MB of archives.\nAfter this operation, 262 MB of additional disk space will be used.\nDo you want to continue? [Y\/n] Y\n<\/em><\/pre>\n\n\n\n<p><strong>\u6bb5\u843d3\u3001MySQL\u7684\u5b89\u5168\u52a0\u56fa<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql_secure_installation<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted has-background\" style=\"background:linear-gradient(135deg,rgb(6,147,227) 0%,rgb(255,255,255) 30%,rgb(241,211,211) 48%,rgb(155,81,224) 100%)\"><em>Press y|Y for Yes, any other key for No: <\/em><strong>y<\/strong>\n\n\n<em>LOW    Length &gt;= 8\nMEDIUM Length &gt;= 8, numeric, mixed case, and special characters\nSTRONG Length &gt;= 8, numeric, mixed case, special characters and dictionary                  file\n\nPlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:<\/em> <strong>2<\/strong>\n\n\/\/ \u6570\u636eMySQL\u6570\u636e\u5e93root\u7528\u6237\u7684\u5bc6\u7801\uff0c\u5bc6\u7801\u53ef\u81ea\u5b9a\u4e49\uff0c\u5047\u8bbe\u5bc6\u7801\u4e3a\uff0c<strong>CbA5_eaC8_b0d4_Ff0a_2b76<\/strong>\uff0c\u8f93\u5165\u5bc6\u7801\u65f6\u5019\uff0c\u5bc6\u7801\u4e0d\u663e\u793a\uff0c\u76f4\u63a5\u8f93\u5165\u6309\u56de\u8f66\n<em>New password: <\/em><strong>CbA5_eaC8_b0d4_Ff0a_2b76<\/strong><em>\nRe-enter new password: <\/em><strong>CbA5_eaC8_b0d4_Ff0a_2b76<\/strong>\n\n\n<em>Estimated strength of the password: 100 \nDo you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : <\/em><strong>Y<\/strong>\n\n\/\/ \u79fb\u9664\u533f\u540d\u7528\u6237\n<em>Remove anonymous users? (Press y|Y for Yes, any other key for No) : <\/em><strong>Y<\/strong>\n\n\/\/ \u7981\u6b62root\u8fdc\u7a0b\u767b\u5f55\n<em>Disallow root login remotely? (Press y|Y for Yes, any other key for No) :<\/em> <strong>N<\/strong>\n\n\/\/ \u79fb\u9664\u6d4b\u8bd5\u5e93\u5b9e\u4f8b\n<em>Remove test database and access to it? (Press y|Y for Yes, any other key for No) : <\/em><strong>Y<\/strong>\n\n\/\/ \u91cd\u8f7d\u4e00\u4e0b\u6743\u9650\n<em>Reload privilege tables now? (Press y|Y for Yes, any other key for No) : <\/em><strong>Y<\/strong>\n<\/pre>\n\n\n\n<p><strong>\u6bb5\u843d4\u3001\u521b\u5efa\u6570\u636e\u5e93\u7684\u666e\u901a\u5e10\u53f7<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>root@UK-d68b93f1d5:~# <\/em><strong>mysql -u root -p<\/strong><em>\nEnter password: \nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 10\nServer version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)\n\nCopyright (c) 2000, 2022, Oracle and\/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql&gt; <\/em>\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ \u6570\u636e\u5e93\u7684\u7248\u672c\u4fe1\u606f\nServer version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)\n\n\/\/ \u8fdb\u5165\u6570\u636e\u5e93\uff0c\u9700\u8981\u8f93\u5165\u521a\u521a\u7684\u5bc6\u7801\nroot@server:~# mysql -u root -p\n\n\/\/ \u521b\u5efa\u6570\u636e\u5e93\u7684\u666e\u901a\u7528\u6237 wordpress\uff0c\u770b\u4f60\u672c\u5730\u7248\u672c\uff0c\u9009\u62e9\u521b\u5efa\u666e\u901a\u7528\u6237\u7684\u547d\u4ee4\uff0c\u4e8c\u9009\u4e00\u6267\u884c\n\/\/ MySQL 8.0, caching_sha2_password is the default authentication plugin\n\/\/ MySQL 5.7, mysql_native_password is the default\nmysql&gt; CREATE USER 'wordpress'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'wordpress_57AADFEF668Ae2E8E6285858';\nmysql&gt; CREATE USER 'wordpress'@'localhost' IDENTIFIED WITH mysql_native_password BY 'wordpress_57AADFEF668Ae2E8E6285858';\n\n\/\/ \u5982\u679c\u662f\u5220\u9664\u666e\u901a\u7528\u6237 wordpress\nmysql&gt; DROP USER 'wordpress'@'localhost';\n\n\/\/ \u5982\u679c\u662f\u5220\u9664\u666e\u901a\u7684\u6570\u636e\u5e93\u5b9e\u4f8b wordpress\nmysql&gt; drop database wordpress;\n\n\/\/ \u67e5\u770b\u6570\u636e\u5e93\u4e2d\u7684\u7528\u6237\nmysql&gt; select User from mysql.user;\n\n\/\/ \u67e5\u770b\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u5e93\u5b9e\u4f8b\nmysql&gt; show databases;\n\n\/\/ \u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b wordpress\n\/\/ MySQL 8.0\u6bd4\u8f83\u63a8\u8350\u4f7f\u7528 utf8mb4\n\/\/ MySQL 5.5\u6bd4\u8f83\u63a8\u8350\u4f7f\u7528 utf8\n\/\/ MySQL supports two kinds of UTF8 character sets: utf8 and utf8mb4\n\/\/ MySQL's utf8mb4 character table is a superset of BMP and contains also 4-bytes characters. This character tables is supported since MySQL 5.5.3\n\/\/ MySQL version 5.5.3 or later, use the utf8mb4 character set\nmysql&gt; create database wordpress character set utf8mb4 collate utf8mb4_bin;\nmysql&gt; create database wordpress character set utf8 collate utf8_bin;\n\n\/\/ \u628a\u666e\u901a\u6570\u636e\u5e93\u8d26\u53f7\u548c\u6570\u636e\u5e93\u5b9e\u4f8b\u5173\u8054\u8d77\u6765\nmysql&gt; GRANT ALL privileges ON wordpress.* to wordpress@localhost;\n\n\/\/ \u4e5f\u53ef\u4ee5\u53ea\u628a\u67d0\u4e2a\u8868\u7684\u6743\u9650\u7ed9\u5230\u6570\u636e\u5e93\u7528\u6237\nmysql&gt; GRANT PRIVILEGE ON wordpress.tablename TO 'wordpress'@'host';\n\n\/\/ \u5982\u679c\u662f\u5355\u9879\u6743\u9650\u7684\u4fee\u6539\uff0c\u53ef\u53c2\u8003\u547d\u4ee4\nmysql&gt; GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on wordpress.* TO 'wordpress'@'localhost' WITH GRANT OPTION;\n\n\/\/ \u6743\u9650\u751f\u6548\nmysql&gt; flush privileges;\n\n\/\/ \u63a8\u51fa\u4ea4\u4e92\nmysql&gt; exit\n\n\/\/ \u67e5\u770bMySQL\u670d\u52a1\u72b6\u6001 \nsystemctl status mysql.service\nsystemctl restart mysql.service<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6bb5\u843d1\u3001\u9700\u6c42 \u5728Ubuntu 20.04 LTS\u73af\u5883\u4e0a\uff0c\u7f16\u8bd1\u5b89\u88c5MySQL\u6570\u636e\u5e93 \u6bb5\u843d2\u3001\u90e8\u7f72\u5b9e\u65bd \u66f4\u65b0\u5305\u7d22\u5f15 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/1544"}],"collection":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1544"}],"version-history":[{"count":14,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/1544\/revisions"}],"predecessor-version":[{"id":1565,"href":"https:\/\/dasmz.com\/index.php?rest_route=\/wp\/v2\/posts\/1544\/revisions\/1565"}],"wp:attachment":[{"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasmz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}