{"id":1533,"date":"2024-05-08T13:54:07","date_gmt":"2024-05-08T05:54:07","guid":{"rendered":"http:\/\/oneai.eu.org\/?p=1533"},"modified":"2024-05-08T13:54:07","modified_gmt":"2024-05-08T05:54:07","slug":"centos7-%e4%b8%8b%e5%ae%89%e8%a3%85mysql","status":"publish","type":"post","link":"https:\/\/oneai.eu.org\/?p=1533","title":{"rendered":"centos7 \u4e0b\u5b89\u88c5mysql"},"content":{"rendered":"<p>CentOS7\u5b89\u88c5MySQL<br \/>\n\u5728CentOS\u4e2d\u9ed8\u8ba4\u5b89\u88c5\u6709MariaDB\uff0c\u8fd9\u4e2a\u662fMySQL\u7684\u5206\u652f\uff0c\u4f46\u4e3a\u4e86\u9700\u8981\uff0c\u8fd8\u662f\u8981\u5728\u7cfb\u7edf\u4e2d\u5b89\u88c5MySQL\uff0c\u800c\u4e14\u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\u53ef\u4ee5\u76f4\u63a5\u8986\u76d6\u6389MariaDB\u3002<\/p>\n<p>1 \u4e0b\u8f7d\u5e76\u5b89\u88c5MySQL\u5b98\u65b9\u7684 Yum Repository<br \/>\n[root@localhost ~]# wget -i -c <a href=\"http:\/\/dev.mysql.com\/get\/mysql57-community-release-el7-10.noarch.rpm\">http:\/\/dev.mysql.com\/get\/mysql57-community-release-el7-10.noarch.rpm<\/a><br \/>\n\u4f7f\u7528\u4e0a\u9762\u7684\u547d\u4ee4\u5c31\u76f4\u63a5\u4e0b\u8f7d\u4e86\u5b89\u88c5\u7528\u7684Yum Repository\uff0c\u5927\u698225KB\u7684\u6837\u5b50\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u76f4\u63a5yum\u5b89\u88c5\u4e86\u3002<\/p>\n<p>[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm<br \/>\n\u4e4b\u540e\u5c31\u5f00\u59cb\u5b89\u88c5MySQL\u670d\u52a1\u5668\u3002<\/p>\n<p>[root@localhost ~]# yum -y install mysql-community-server<br \/>\n\u8fd9\u6b65\u53ef\u80fd\u4f1a\u82b1\u4e9b\u65f6\u95f4\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\u5c31\u4f1a\u8986\u76d6\u6389\u4e4b\u524d\u7684mariadb\u3002<\/p>\n<p>\u81f3\u6b64MySQL\u5c31\u5b89\u88c5\u5b8c\u6210\u4e86\uff0c\u7136\u540e\u662f\u5bf9MySQL\u7684\u4e00\u4e9b\u8bbe\u7f6e\u3002<\/p>\n<p>2 MySQL\u6570\u636e\u5e93\u8bbe\u7f6e<br \/>\n\u9996\u5148\u542f\u52a8MySQL<\/p>\n<p>[root@localhost ~]# systemctl start  mysqld.service<br \/>\n\u67e5\u770bMySQL\u8fd0\u884c\u72b6\u6001\uff0c\u8fd0\u884c\u72b6\u6001\u5982\u56fe\uff1a<\/p>\n<p>[root@localhost ~]# systemctl status mysqld.service<\/p>\n<p>\u6b64\u65f6MySQL\u5df2\u7ecf\u5f00\u59cb\u6b63\u5e38\u8fd0\u884c\uff0c\u4e0d\u8fc7\u8981\u60f3\u8fdb\u5165MySQL\u8fd8\u5f97\u5148\u627e\u51fa\u6b64\u65f6root\u7528\u6237\u7684\u5bc6\u7801\uff0c\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5728\u65e5\u5fd7\u6587\u4ef6\u4e2d\u627e\u51fa\u5bc6\u7801\uff1a<\/p>\n<p>[root@localhost ~]# grep &quot;password&quot; \/var\/log\/mysqld.log<\/p>\n<p>\u5982\u4e0b\u547d\u4ee4\u8fdb\u5165\u6570\u636e\u5e93\uff1a<\/p>\n<p>[root@localhost ~]# mysql -uroot -p<br \/>\n\u8f93\u5165\u521d\u59cb\u5bc6\u7801\uff0c\u6b64\u65f6\u4e0d\u80fd\u505a\u4efb\u4f55\u4e8b\u60c5\uff0c\u56e0\u4e3aMySQL\u9ed8\u8ba4\u5fc5\u987b\u4fee\u6539\u5bc6\u7801\u4e4b\u540e\u624d\u80fd\u64cd\u4f5c\u6570\u636e\u5e93\uff1a<\/p>\n<p>mysql&gt; ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';<br \/>\n\u8fd9\u91cc\u6709\u4e2a\u95ee\u9898\uff0c\u65b0\u5bc6\u7801\u8bbe\u7f6e\u7684\u65f6\u5019\u5982\u679c\u8bbe\u7f6e\u7684\u8fc7\u4e8e\u7b80\u5355\u4f1a\u62a5\u9519\uff1a<\/p>\n<p>\u539f\u56e0\u662f\u56e0\u4e3aMySQL\u6709\u5bc6\u7801\u8bbe\u7f6e\u7684\u89c4\u8303\uff0c\u5177\u4f53\u662f\u4e0evalidate_password_policy\u7684\u503c\u6709\u5173\uff1a<\/p>\n<p>MySQL\u5b8c\u6574\u7684\u521d\u59cb\u5bc6\u7801\u89c4\u5219\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u67e5\u770b\uff1a<\/p>\n<p>\u590d\u5236\u4ee3\u7801<br \/>\nmysql&gt; SHOW VARIABLES LIKE 'validate_password%';<br \/>\n+--------------------------------------+-------+<br \/>\n| Variable_name                        | Value |<br \/>\n+--------------------------------------+-------+<br \/>\n| validate_password_check_user_name    | OFF   |<br \/>\n| validate_password_dictionary_file    |       |<br \/>\n| validate_password_length             | 4     |<br \/>\n| validate_password_mixed_case_count   | 1     |<br \/>\n| validate_password_number_count       | 1     |<br \/>\n| validate_password_policy             | LOW   |<br \/>\n| validate_password_special_char_count | 1     |<br \/>\n+--------------------------------------+-------+<br \/>\n7 rows in set (0.01 sec)<br \/>\n\u590d\u5236\u4ee3\u7801<br \/>\n\u5bc6\u7801\u7684\u957f\u5ea6\u662f\u7531validate_password_length\u51b3\u5b9a\u7684\uff0c\u800cvalidate_password_length\u7684\u8ba1\u7b97\u516c\u5f0f\u662f\uff1a<\/p>\n<p>validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)<\/p>\n<p>\u6211\u7684\u662f\u5df2\u7ecf\u4fee\u6539\u8fc7\u7684\uff0c\u521d\u59cb\u60c5\u51b5\u4e0b\u7b2c\u4e00\u4e2a\u7684\u503c\u662fON\uff0cvalidate_password_length\u662f8\u3002\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u4fee\u6539\uff1a<\/p>\n<p>mysql&gt; set global validate_password_policy=0;<br \/>\nmysql&gt; set global validate_password_length=1;<br \/>\n\u8bbe\u7f6e\u4e4b\u540e\u5c31\u662f\u6211\u4e0a\u9762\u67e5\u51fa\u6765\u7684\u90a3\u51e0\u4e2a\u503c\u4e86\uff0c\u6b64\u65f6\u5bc6\u7801\u5c31\u53ef\u4ee5\u8bbe\u7f6e\u7684\u5f88\u7b80\u5355\uff0c\u4f8b\u59821234\u4e4b\u7c7b\u7684\u3002\u5230\u6b64\u6570\u636e\u5e93\u7684\u5bc6\u7801\u8bbe\u7f6e\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n<p>\u4f46\u6b64\u65f6\u8fd8\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u56e0\u4e3a\u5b89\u88c5\u4e86Yum Repository\uff0c\u4ee5\u540e\u6bcf\u6b21yum\u64cd\u4f5c\u90fd\u4f1a\u81ea\u52a8\u66f4\u65b0\uff0c\u9700\u8981\u628a\u8fd9\u4e2a\u5378\u8f7d\u6389\uff1a<\/p>\n<p>[root@localhost ~]# yum -y remove mysql57-community-release-el7-10.noarch<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS7\u5b89\u88c5MySQL \u5728CentOS\u4e2d\u9ed8\u8ba4\u5b89\u88c5\u6709MariaDB\uff0c\u8fd9\u4e2a\u662fMySQL\u7684\u5206\u652f\uff0c\u4f46\u4e3a\u4e86\u9700\u8981\uff0c\u8fd8\u662f\u8981\u5728\u7cfb\u7edf\u4e2d\u5b89\u88c5MySQL\uff0c\u800c\u4e14\u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\u53ef\u4ee5\u76f4\u63a5\u8986\u76d6\u6389MariaDB\u3002 1 \u4e0b\u8f7d\u5e76\u5b89\u88c5MySQL\u5b98\u65b9\u7684 Yum Repository [root@localhost ~]# wget -i -c http:\/\/dev.mysql.com\/get\/mysql57-community-release-el7-10.noarch.rpm \u4f7f\u7528\u4e0a\u9762\u7684\u547d\u4ee4\u5c31\u76f4\u63a5\u4e0b\u8f7d\u4e86\u5b89\u88c5\u7528\u7684Yum Repository\uff0c\u5927\u698225KB\u7684\u6837\u5b50\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u76f4\u63a5yum\u5b89\u88c5\u4e86\u3002 [root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm \u4e4b\u540e\u5c31\u5f00\u59cb\u5b89\u88c5MySQL\u670d\u52a1\u5668\u3002 [root@localhost ~]# yum -y install mysql-community-server \u8fd9\u6b65\u53ef\u80fd\u4f1a\u82b1\u4e9b\u65f6\u95f4\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\u5c31\u4f1a\u8986\u76d6\u6389\u4e4b\u524d\u7684mariadb\u3002 \u81f3\u6b64MySQL\u5c31\u5b89\u88c5\u5b8c\u6210\u4e86\uff0c\u7136\u540e\u662f\u5bf9MySQL\u7684\u4e00\u4e9b\u8bbe\u7f6e\u3002 2 MySQL\u6570\u636e\u5e93\u8bbe\u7f6e \u9996\u5148\u542f\u52a8MySQL [root@localhost ~]# systemctl start mysqld.service \u67e5\u770bMySQL\u8fd0\u884c\u72b6\u6001\uff0c\u8fd0\u884c\u72b6\u6001\u5982\u56fe\uff1a [root@localhost ~]# systemctl status mysqld.service \u6b64\u65f6MySQL\u5df2\u7ecf\u5f00\u59cb\u6b63\u5e38\u8fd0\u884c\uff0c\u4e0d\u8fc7\u8981\u60f3\u8fdb\u5165MySQL\u8fd8\u5f97\u5148\u627e\u51fa\u6b64\u65f6root\u7528\u6237\u7684\u5bc6\u7801\uff0c\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u53ef\u4ee5\u5728\u65e5\u5fd7\u6587\u4ef6\u4e2d\u627e\u51fa\u5bc6\u7801\uff1a [root@localhost ~]# grep &quot;password&quot; \/var\/log\/mysqld.log \u5982\u4e0b\u547d\u4ee4\u8fdb\u5165\u6570\u636e\u5e93\uff1a [root@localhost ~]# mysql -uroot -p \u8f93\u5165\u521d\u59cb\u5bc6\u7801\uff0c\u6b64\u65f6\u4e0d\u80fd\u505a\u4efb\u4f55\u4e8b\u60c5\uff0c\u56e0\u4e3aMySQL\u9ed8\u8ba4\u5fc5\u987b\u4fee\u6539\u5bc6\u7801\u4e4b\u540e\u624d\u80fd\u64cd\u4f5c\u6570\u636e\u5e93\uff1a mysql&gt; ALTER USER &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;new password&#8217;; \u8fd9\u91cc\u6709\u4e2a\u95ee\u9898\uff0c\u65b0\u5bc6\u7801\u8bbe\u7f6e\u7684\u65f6\u5019\u5982\u679c\u8bbe\u7f6e\u7684\u8fc7\u4e8e\u7b80\u5355\u4f1a\u62a5\u9519\uff1a \u539f\u56e0\u662f\u56e0\u4e3aMySQL\u6709\u5bc6\u7801\u8bbe\u7f6e\u7684\u89c4\u8303\uff0c\u5177\u4f53\u662f\u4e0evalidate_password_policy\u7684\u503c\u6709\u5173\uff1a MySQL\u5b8c\u6574\u7684\u521d\u59cb\u5bc6\u7801\u89c4\u5219\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u67e5\u770b\uff1a \u590d\u5236\u4ee3\u7801 mysql&gt; SHOW VARIABLES LIKE &#8216;validate_password%&#8217;; +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+ | Variable_name | Value | +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+ | validate_password_check_user_name | OFF | | validate_password_dictionary_file | | | validate_password_length | 4 | | validate_password_mixed_case_count | 1 | | validate_password_number_count | 1 | | validate_password_policy | LOW | | validate_password_special_char_count | 1 | +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+ 7 rows in set (0.01 sec) \u590d\u5236\u4ee3\u7801 \u5bc6\u7801\u7684\u957f\u5ea6\u662f\u7531validate_password_length\u51b3\u5b9a\u7684\uff0c\u800cvalidate_password_length\u7684\u8ba1\u7b97\u516c\u5f0f\u662f\uff1a validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count) \u6211\u7684\u662f\u5df2\u7ecf\u4fee\u6539\u8fc7\u7684\uff0c\u521d\u59cb\u60c5\u51b5\u4e0b\u7b2c\u4e00\u4e2a\u7684\u503c\u662fON\uff0cvalidate_password_length\u662f8\u3002\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u4fee\u6539\uff1a mysql&gt; set global validate_password_policy=0; mysql&gt; set global validate_password_length=1; \u8bbe\u7f6e\u4e4b\u540e\u5c31\u662f\u6211\u4e0a\u9762\u67e5\u51fa\u6765\u7684\u90a3\u51e0\u4e2a\u503c\u4e86\uff0c\u6b64\u65f6\u5bc6\u7801\u5c31\u53ef\u4ee5\u8bbe\u7f6e\u7684\u5f88\u7b80\u5355\uff0c\u4f8b\u59821234\u4e4b\u7c7b\u7684\u3002\u5230\u6b64\u6570\u636e\u5e93\u7684\u5bc6\u7801&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[99,83],"tags":[],"class_list":["post-1533","post","type-post","status-publish","format-standard","hentry","category-centos","category-mysql"],"_links":{"self":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1533"}],"version-history":[{"count":1,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1533\/revisions"}],"predecessor-version":[{"id":1534,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1533\/revisions\/1534"}],"wp:attachment":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}