{"id":650,"date":"2023-02-26T13:41:07","date_gmt":"2023-02-26T05:41:07","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=650"},"modified":"2023-04-29T19:24:37","modified_gmt":"2023-04-29T11:24:37","slug":"mysql-installation-and-configuration-under-windows","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/mysql-installation-and-configuration-under-windows\/","title":{"rendered":"Windows\u4e0bMySQL\u5b89\u88c5\u53ca\u914d\u7f6e"},"content":{"rendered":"<h2>my.ini \u914d\u7f6e<\/h2>\n<p>\u5b98\u65b9\u4e0b\u8f7d\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/dev.mysql.com\/downloads\/mirrors\/\">http:\/\/dev.mysql.com\/downloads\/mirrors\/<\/a><\/p>\n<p>\u590d\u5236 my-default.ini \u4e3a my.ini<\/p>\n<p><!-- more --><\/p>\n<pre><code>[mysqld]\nexplicit_defaults_for_timestamp = true\nbasedir = &quot;D:\/Server\/MySQL\/mysql-5.7.20-winx64&quot;\ndatadir = &quot;D:\/Server\/MySQL\/mysql-5.7.20-winx64\/data&quot;\nsocket = &quot;D:\/Server\/MySQL\/mysql-5.7.20-winx64\/tmp\/mysql.sock&quot;\nport = 3306\ncharacter_set_server = utf8    # \u8bbe\u7f6eMySQL\u670d\u52a1\u5668\u9ed8\u8ba4\u5b57\u7b26\u96c6\uff08\u53ef\u9009\uff09\nsql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\n\n[client]\ndefault_character_set = utf8    # \u8bbe\u7f6eMySQL\u5ba2\u6237\u7aef\u9ed8\u8ba4\u5b57\u7b26\u96c6\uff08\u53ef\u9009\uff09<\/code><\/pre>\n<h2>\u521d\u59cb\u5316\u5e76\u5b89\u88c5\u670d\u52a1<\/h2>\n<p>Install MySQL Service.bat<\/p>\n<pre><code>@echo off\nset mysql_home=D:\/Server\/MySQL\/mysql-5.7.20-winx64\n\necho Installing MySQL5.7 Service...\n%mysql_home%\/bin\/mysqld --install &quot;MySQL5.7&quot; --defaults-file=&quot;%mysql_home%\/my.ini&quot;\n%mysql_home%\/bin\/mysqld --initialize --user=mysql --console\n\npause<\/code><\/pre>\n<p>\u4e5f\u53ef\u4ee5\u5355\u72ec\u6267\u884cmysqld &#8211;initialize\u521d\u59cb\u5316\u6570\u636e\uff0c\u6ce8\u610f\u8bb0\u5f55\u9ed8\u8ba4\u751f\u6210\u7684root\u7528\u6237\u5bc6\u7801<\/p>\n<pre><code>D:\\Server\\MySQL\\mysql-5.7.20-winx64\\bin&gt;mysqld --initialize --user=mysql --console\n2017-11-21T13:23:04.415538Z 0 [Warning] InnoDB: New log files created, LSN=45790\n2017-11-21T13:23:04.460653Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.\n2017-11-21T13:23:04.526828Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a23b05a6-afed-11e6-869d-704d7b36dddd.\n2017-11-21T13:23:04.528835Z 0 [Warning] Gtid table is not ready to be used. Table &#039;mysql.gtid_executed&#039; cannot be opened.\n2017-11-21T13:23:04.533849Z 1 [Note] A temporary password is generated for root@localhost: Hq?E7tajGi\/e<\/code><\/pre>\n<h2>\u542f\u52a8\u670d\u52a1<\/h2>\n<p>Start MySQL Service.bat<\/p>\n<pre><code>@echo off\n\necho Starting MySQL5.7 Service...\nnet start MySQL5.7\n\npause<\/code><\/pre>\n<h2>\u505c\u6b62\u548c\u5378\u8f7d\u670d\u52a1<\/h2>\n<p>Stop MySQL Service.bat<\/p>\n<pre><code>@echo off\n\necho Stoping MySQL5.7 Service...\nnet stop MySQL5.7\n\npause<\/code><\/pre>\n<p>Uninstall MySQL Service.bat<\/p>\n<pre><code>@echo off\nset mysql_home=D:\/Server\/MySQL\/mysql-5.7.20-winx64\n\necho Uninstalling MySQL5.7 Service...\n%mysql_home%\/bin\/mysqld.exe --remove &quot;MySQL5.7&quot;\n\npause<\/code><\/pre>\n<h2>\u4fee\u6539root\u7528\u6237\u5bc6\u7801<\/h2>\n<pre><code>mysql&gt; set password = password(&#039;ubuntu&#039;);\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nmysql&gt; alter user &#039;root&#039;@&#039;localhost&#039; password expire never;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql&gt; flush privileges;\nQuery OK, 0 rows affected (0.00 sec)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>my.ini \u914d\u7f6e \u5b98\u65b9\u4e0b\u8f7d\uff1ahttp:\/\/dev.mysql.com\/downloads\/mirrors\/  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-650","post","type-post","status-publish","format-standard","hentry","category-devops-base"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=650"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/650\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}