{"id":1396,"date":"2020-05-25T18:12:43","date_gmt":"2020-05-25T10:12:43","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1396"},"modified":"2020-05-25T18:12:43","modified_gmt":"2020-05-25T10:12:43","slug":"mysql-5-7%e5%ae%89%e8%a3%85%e4%b8%8e%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1396","title":{"rendered":"MySQL 5.7\u5b89\u88c5\u4e0e\u914d\u7f6e"},"content":{"rendered":"<div>\n<h3>\u5b89\u88c5\u73af\u5883\uff1a<\/h3>\n<ul>\n<li>CentOS 7 64-bit Minimal<\/li>\n<li>MySQL 5.7<\/li>\n<\/ul>\n<h3>\u914d\u7f6e yum \u6e90<\/h3>\n<ul>\n<li><strong>\u901a\u8fc7\u5b98\u7f51\u4e0b\u8f7d\u5730\u5740\uff0c\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002<\/strong><\/li>\n<\/ul>\n<pre>https:\/\/dev.mysql.com\/downloads\/repo\/yum\/<\/pre>\n<div class=\\\"image-package\\\">\n<div class=\\\"image-container\\\">\n<ul>\n<li class=\\\"image-container-fill\\\"><strong><span style=\\\"font-size: 16px;\\\">\u5b89\u88c5 MySQL yum\u6e90<\/span><\/strong><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div>\n<pre># \u4e0b\u8f7d\nwget https:\/\/dev.mysql.com\/get\/mysql57-community-release-el7-11.noarch.rpm\n# \u5b89\u88c5 MySQL \u6e90\nyum localinstall mysql57-community-release-el7-11.noarch.rpm -y\n<\/pre>\n<\/div>\n<ul>\n<li><strong>\u68c0\u67e5 mysql \u6e90\u662f\u5426\u5b89\u88c5\u6210\u529f<\/strong><\/li>\n<\/ul>\n<div class=\\\"_2Uzcx_\\\">\n<pre>yum repolist enabled | grep mysql\nmysql-connectors-community\/x86_64 MySQL Connectors Community                 153\nmysql-tools-community\/x86_64      MySQL Tools Community                      110\nmysql57-community\/x86_64          MySQL 5.7 Community Server                 424<\/pre>\n<\/div>\n<div class=\\\"image-package\\\">\n<div class=\\\"image-caption\\\"><\/div>\n<\/div>\n<h2>\u5b89\u88c5 MySQL<\/h2>\n<div class=\\\"_2Uzcx_\\\">\n<pre>yum install -y mysql-community-server\n<\/pre>\n<\/div>\n<ul>\n<li>\u542f\u52a8 MySQL \u670d\u52a1<\/li>\n<\/ul>\n<pre>systemctl start mysqld\n<\/pre>\n<ul>\n<li>\u67e5\u770b MySQL \u72b6\u6001<\/li>\n<\/ul>\n<pre>systemctl status mysqld<\/pre>\n<ul>\n<li>\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8<\/li>\n<\/ul>\n<div>\n<pre>systemctl enable mysqld\n# \u91cd\u8f7d\u6240\u6709\u4fee\u6539\u8fc7\u7684\u914d\u7f6e\u6587\u4ef6\nsystemctl daemon-reload<\/pre>\n<\/div>\n<\/div>\n<h2>\u914d\u7f6eMySQL<\/h2>\n<p>&nbsp;<\/p>\n<div>\n<ul>\n<li>\u4fee\u6539 root \u672c\u5730\u8d26\u6237\u5bc6\u7801<\/li>\n<\/ul>\n<p>mysql \u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\uff0c\u751f\u6210\u7684\u9ed8\u8ba4\u5bc6\u7801\u5728 \/var\/log\/mysqld.log \u6587\u4ef6\u4e2d\u3002\u4f7f\u7528 grep \u547d\u4ee4\u627e\u5230\u65e5\u5fd7\u4e2d\u7684\u5bc6\u7801\u3002<\/p>\n<pre>grep \\'temporary password\\' \/var\/log\/mysqld.log<\/pre>\n<div class=\\\"image-package\\\">\n<div class=\\\"image-container\\\">\n<div class=\\\"image-view\\\" data-width=\\\"1137\\\" data-height=\\\"102\\\"><\/div>\n<\/div>\n<div class=\\\"image-caption\\\">\u67e5\u770b\u4e34\u65f6\u5bc6\u7801<\/div>\n<\/div>\n<p>\u9996\u6b21\u901a\u8fc7\u521d\u59cb\u5bc6\u7801\u767b\u5f55\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4fee\u6539\u5bc6\u7801<\/p>\n<div>\n<pre>mysql -uroot -p\nALTER USER \\'root\\'@\\'localhost\\' IDENTIFIED BY \\'MyNewPass4!\\';\n# \u6216\nset password for \\'root\\'@\\'localhost\\'=password(\\'MyNewPass4!\\');<\/pre>\n<\/div>\n<p>\u4ee5\u540e\u901a\u8fc7 update set \u8bed\u53e5\u4fee\u6539\u5bc6\u7801<\/p>\n<div>\n<pre>mysql&gt; use mysql;\nmysql&gt; update user set password=PASSWORD(\\'MyNewPass5!\\') where user=\\'root\\';\nmysql&gt; flush privileges;\n<\/pre>\n<\/div>\n<blockquote><p>\u6ce8\u610f\uff1amysql 5.7 \u9ed8\u8ba4\u5b89\u88c5\u4e86\u5bc6\u7801\u5b89\u5168\u68c0\u67e5\u63d2\u4ef6\uff08validate_password\uff09\uff0c\u9ed8\u8ba4\u5bc6\u7801\u68c0\u67e5\u7b56\u7565\u8981\u6c42\u5bc6\u7801\u5fc5\u987b\u5305\u542b\uff1a\u5927\u5c0f\u5199\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u7279\u6b8a\u7b26\u53f7\uff0c\u5e76\u4e14\u957f\u5ea6\u4e0d\u80fd\u5c11\u4e8e8\u4f4d\u3002\u5426\u5219\u4f1a\u63d0\u793a ERROR 1819 (HY000): Your password does not satisfy the current policy requirements \u9519\u8bef\u3002\u67e5\u770b <a href=\\\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Fvalidate-password-options-variables.html%23sysvar_validate_password_policy\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">MySQL\u5b98\u7f51\u5bc6\u7801\u8be6\u7ec6\u7b56\u7565<\/a><\/p><\/blockquote>\n<ul>\n<li>\u6dfb\u52a0\u8fdc\u7a0b\u767b\u5f55\u7528\u6237<\/li>\n<\/ul>\n<p>\u9ed8\u8ba4\u53ea\u5141\u8bb8root\u5e10\u6237\u5728\u672c\u5730\u767b\u5f55\uff0c\u5982\u679c\u8981\u5728\u5176\u5b83\u673a\u5668\u4e0a\u8fde\u63a5mysql\uff0c\u5fc5\u987b\u6dfb\u52a0\u4e00\u4e2a\u5141\u8bb8\u8fdc\u7a0b\u8fde\u63a5\u7684\u5e10\u6237\u3002<\/p>\n<div>\n<pre>mysql&gt; GRANT ALL PRIVILEGES ON *.* TO \\'weijing\\'@\\'%\\' IDENTIFIED BY \\'Weijing2020!\\' WITH GRANT OPTION;\n<\/pre>\n<\/div>\n<p>\u4fee\u6539 root \u4e3a\u5141\u8bb8\u8fdc\u7a0b\u8fde\u63a5<\/p>\n<div>\n<pre>mysql&gt; use mysql;\nmysql&gt; UPDATE user SET Host=\\'%\\' WHERE User=\\'root\\';\nmysql&gt; flush privileges;<\/pre>\n<\/div>\n<ul>\n<li>\u8bbe\u7f6e\u9ed8\u8ba4\u7f16\u7801\u4e3a utf8<\/li>\n<\/ul>\n<p>mysql \u5b89\u88c5\u540e\u9ed8\u8ba4\u4e0d\u652f\u6301\u4e2d\u6587\uff0c\u901a\u8fc7\u4fee\u6539\/etc\/my.cnf\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<div>\n<pre>[mysql]\ndefault-character-set=utf8\n[client]\ndefault-character-set = utf8\n[mysqld]\ndefault-storage-engine = INNODB\ncharacter-set-server = utf8\ncollation-server = utf8_general_ci #\u4e0d\u533a\u5206\u5927\u5c0f\u5199\ncollation-server =  utf8_bin #\u533a\u5206\u5927\u5c0f\u5199\ncollation-server = utf8_unicode_ci #\u6bd4 utf8_general_ci \u66f4\u51c6\u786e<\/pre>\n<\/div>\n<p>\u91cd\u542fmysql\u670d\u52a1\uff0c\u67e5\u8be2\u7f16\u7801\u3002\u53ef\u4ee5\u770b\u5230\u5df2\u7ecf\u6539\u8fc7\u6765\u4e86<\/p>\n<div>\n<pre>systemctl restart mysqld\nmysql -uroot -p\nshow variables like \\'character%\\';<\/pre>\n<\/div>\n<div class=\\\"image-package\\\">\n<div class=\\\"image-container\\\"><\/div>\n<\/div>\n<ul>\n<li>\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff1a<\/li>\n<\/ul>\n<pre># \u914d\u7f6e\u6587\u4ef6\uff1a\n\/etc\/my.cnf\n# \u65e5\u5fd7\u6587\u4ef6\uff1a\n\/var\/log\/mysqld.log\n# \u670d\u52a1\u542f\u52a8\u811a\u672c\uff1a\n\/usr\/lib\/systemd\/system\/mysqld.service\n# socket\u6587\u4ef6\uff1a\n\/var\/run\/mysqld\/mysqld.pid<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u73af\u5883\uff1a CentOS 7 64-bit Minimal MySQL 5.7 \u914d\u7f6e yum \u6e90 \u901a\u8fc7\u5b98\u7f51\u4e0b\u8f7d &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1396\"> <span class=\"screen-reader-text\">MySQL 5.7\u5b89\u88c5\u4e0e\u914d\u7f6e<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[90],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":1,"uagb_excerpt":"\u5b89\u88c5\u73af\u5883\uff1a CentOS 7 64-bit Minimal MySQL 5.7 \u914d\u7f6e yum \u6e90 \u901a\u8fc7\u5b98\u7f51\u4e0b\u8f7d&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1396"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1396"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1396\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1396"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}