<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[元夕的小破站]]></title><description><![CDATA[哈喽~欢迎光临]]></description><link>https://yuanxi953.cn</link><image><url>https://yuanxi953.cnhttps://yuanxi953.cn/api/v2/objects/avatar/fkjias3dnumpwi48ae.png</url><title>元夕的小破站</title><link>https://yuanxi953.cn</link></image><generator>Shiro (https://github.com/Innei/Shiro)</generator><lastBuildDate>Sat, 04 Apr 2026 19:09:10 GMT</lastBuildDate><atom:link href="https://yuanxi953.cn/feed" rel="self" type="application/rss+xml"/><pubDate>Sat, 04 Apr 2026 19:09:10 GMT</pubDate><language><![CDATA[zh-CN]]></language><item><title><![CDATA[MySQL 的安装 For Windows（存档版本）]]></title><description><![CDATA[<link rel="preload" as="image" href="https://lsky.yuanxi953.cn:4433/i/2024/06/04/665e756b152b1.png"/><link rel="preload" as="image" href="https://lsky.yuanxi953.cn:4433/i/2024/06/04/665e8731f17b1.png"/><link rel="preload" as="image" href="https://lsky.yuanxi953.cn:4433/i/2024/06/04/665e87e939df5.png"/><link rel="preload" as="image" href="https://lsky.yuanxi953.cn:4433/i/2024/06/04/665e92e8f2608.png"/><link rel="preload" as="image" href="https://lsky.yuanxi953.cn:4433/i/2024/06/06/6661154b786a2.png"/><link rel="preload" as="image" href="https://lsky.yuanxi953.cn:4433/i/2024/06/06/66611702793f8.png"/><link rel="preload" as="image" href="https://lsky.yuanxi953.cn:4433/i/2024/06/06/666110c63f92d.png"/><div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://yuanxi953.cn/posts/default/MySQL_For_Windows_Install">https://yuanxi953.cn/posts/default/MySQL_For_Windows_Install</a></blockquote><div><h2 id="">目标</h2><ul><li>找到官网并安装当前最新版MySQL</li><li>解决安装时遇到的问题</li><li>解决<code>DBeaver</code>、<code>Navicat</code>等数据库连接工具连接数据库时遇到的部分问题</li></ul><h2 id="">找官网</h2><p><a href="https://www.mysql.com" title="直达官网">MySQL</a></p><pre class=""><code class="">https://www.mysql.com</code></pre><h2 id="">下载所需的版本</h2><p><a href="https://alist.yuanxi953.cn:4433/Blog/MySQL%E4%B8%8B%E8%BD%BD.mkv">教程视频</a></p><video src="https://alist.yuanxi953.cn:4433/d/%E5%AE%B6%E9%87%8C%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%BB%E6%9C%BA/Open/Blog/MySQL%E4%B8%8B%E8%BD%BD.mkv?sign=3Jm4OdxSO-Gx_6JAacaZ8gAKQ7P1yDGRIR5CZOltalY=:0" controls=""></video><h2 id="">安装</h2><h3 id="">解压</h3><p>将下载好的<code>mysql-x.x.x-winx64.zip</code>文件解压，将解压得到的<code>mysql-x.x.x-winx64</code>文件夹移动或复制到其他你想要安装到的位置，比如我打算安装在<code>D:\Program Files</code>下，那么<code>MySQL</code>的根目录为<code>D:\Program Files\mysql-8.4.0-winx64</code></p><h4 id="">目录结构</h4><pre class=""><code class="">D:\PROGRAM FILES\MYSQL-8.4.0-WINX64
├─ LICENSE
├─ my.ini
├─ README
├─bin
│  └─sasl2
├─data
│  ├─#innodb_redo
│  ├─#innodb_temp
│  ├─mysql
│  ├─performance_schema
│  └─sys
├─docs
├─include
│  ├─mysql
│  └─openssl
├─lib
│  ├─mecab
│  │  ├─dic
│  │  │  ├─ipadic_euc-jp
│  │  │  ├─ipadic_sjis
│  │  │  └─ipadic_utf-8
│  │  └─etc
│  ├─plugin
│  │  └─debug
│  └─private
│      └─icudt73l
│          └─brkitr
└─share
    ├─bulgarian
    ├─charsets
    ├─czech
    └─···</code></pre><h3 id="myini">配置<code>my.ini</code></h3><p>将<code>my.ini</code>文件写入到<code>MySQL</code>的根目录下（默认是没有这个<code>my.ini</code>文件的，需要自己新建）</p><pre class="language-ini lang-ini"><code class="language-ini lang-ini">[mysql]
  # 设置mysql客户端默认编码
default-character-set=utf8
[mysqld]
  # 设置mysql8.0的安装目录,填写`MySQL`的根目录,将路径`\`换为`\\`
basedir=D:\\Program Files\\mysql-8.4.0-winx64
[client]
  #设置客户端编码
default-character-set=utf8</code></pre><h3 id="">配置环境变量</h3><p>[视频（还没录）]</p><h3 id="mysql">初始化MySQL</h3><p>使用 <strong>管理员身份（必须，不然后面会报权限错误）</strong> 打开<code>cmd</code>或者<code>powershell</code>,输入以下初始化命令，会获得一个临时root账户的密码，需要复制下来，对后面的步骤很重要</p><pre class="language-cmd lang-cmd"><code class="language-cmd lang-cmd">mysqld --initialize --console</code></pre><p>输入与输出：</p><pre class="language-log lang-log"><code class="language-log lang-log">C:\Users\Administrator&gt;mysqld --initialize --console
2024-06-04T01:57:59.068475Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2024-06-04T01:57:59.074681Z 0 [System] [MY-013169] [Server] C:\Program Files\mysql-8.4.0-winx64\bin\mysqld.exe (mysqld 8.4.0) initializing of server in progress as process 21460
2024-06-04T01:57:59.115670Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-06-04T01:57:59.599542Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-06-04T01:58:01.104784Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: kq7vybL/fJ&lt;j
2024-06-04T01:58:03.177166Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.</code></pre><p><img src="https://lsky.yuanxi953.cn:4433/i/2024/06/04/665e756b152b1.png"/></p><p>日志中可见，我的<code>root</code>用户临时密码为<code>kq7vybL/fJ&lt;j</code></p><h3 id="mysql">安装mysql</h3><p>在刚打开的<code>cmd</code>或者<code>powershell</code>,输入以下命令</p><pre class="language-cmd lang-cmd"><code class="language-cmd lang-cmd">mysqld --install</code></pre><p>输入与输出</p><pre class="language-log lang-log"><code class="language-log lang-log">C:\Users\Administrator&gt;mysqld --install
Service successfully installed.</code></pre><p><img src="https://lsky.yuanxi953.cn:4433/i/2024/06/04/665e8731f17b1.png"/></p><h3 id="">启动服务</h3><p>继续输入以下命令</p><pre class="language-cmd lang-cmd"><code class="language-cmd lang-cmd">net start mysql</code></pre><p>输入与输出</p><pre class="language-log lang-log"><code class="language-log lang-log">C:\Users\Administrator&gt;net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。</code></pre><p><img src="https://lsky.yuanxi953.cn:4433/i/2024/06/04/665e87e939df5.png"/></p><h3 id="mysql">登录MySQL</h3><pre class="language-cmd lang-cmd"><code class="language-cmd lang-cmd">C:\Users\Administrator&gt;mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.4.0

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type &#x27;help;&#x27; or &#x27;\h&#x27; for help. Type &#x27;\c&#x27; to clear the current input statement.

mysql&gt;</code></pre><pre class="language-log lang-log"><code class="language-log lang-log">C:\Users\Administrator&gt;mysql -uroot -p
Enter password:</code></pre><h3 id="">设置新密码</h3><p>我想将<code>root</code>用户的密码设置为<code>root1234</code>，输入以下命令</p><pre class="language-cmd lang-cmd"><code class="language-cmd lang-cmd">set password for &#x27;root&#x27;@&#x27;localhost&#x27;=&#x27;root1234&#x27;;</code></pre><p>输入与输出：</p><pre class="language-log lang-log"><code class="language-log lang-log">mysql&gt; set password for &#x27;root&#x27;@&#x27;localhost&#x27;=&#x27;root1234&#x27;;
Query OK, 0 rows affected (0.02 sec)</code></pre><p><img src="https://lsky.yuanxi953.cn:4433/i/2024/06/04/665e92e8f2608.png"/></p><h2 id="mysql">卸载MySQL</h2><p>退出登录状态</p><pre class="language-cmd lang-cmd"><code class="language-cmd lang-cmd">\q</code></pre><p>停止服务</p><pre class="language-cmd lang-cmd"><code class="language-cmd lang-cmd">net stop mysql</code></pre><p>卸载</p><pre class="language-cmd lang-cmd"><code class="language-cmd lang-cmd">mysqld -remove mysql</code></pre><p>然后再删掉安装目录的文件就可以了</p><h2 id="">解决疑难杂症</h2><p>使用<code>DBeaver</code>、<code>Navicat</code>等数据库连接工具连接数据库时发生的症状</p><h3 id="1public-key-retrieval-is-not-allowed">问题1：Public Key Retrieval is not allowed</h3><p><img src="https://lsky.yuanxi953.cn:4433/i/2024/06/06/6661154b786a2.png"/></p><h4 id="1">解决方法1</h4><p>可以采用<code>URL</code>连接，在链接末尾加上<code>?allowPublicKeyRetrieval=true</code></p><p>单<code>?</code>表示要连接到的库为空，此时可以在连接工具中连接所有库</p><pre class=""><code class="">jdbc:mysql://localhost:3306/?allowPublicKeyRetrieval=true</code></pre><p><img src="https://lsky.yuanxi953.cn:4433/i/2024/06/06/66611702793f8.png"/></p><h3 id="2null--message-from-server-host-xxxxxxxxxxxx-is-not-allowed-to-connect-to-this-mysql-server">问题2：null,  message from server: &quot;Host &#x27;xxx.xxx.xxx.xxx&#x27; is not allowed to connect to this MySQL server&quot;</h3><p><img src="https://lsky.yuanxi953.cn:4433/i/2024/06/06/666110c63f92d.png"/></p><h4 id="">解决方法</h4></div><p style="text-align:right"><a href="https://yuanxi953.cn/posts/default/MySQL_For_Windows_Install#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://yuanxi953.cn/posts/default/MySQL_For_Windows_Install</link><guid isPermaLink="true">https://yuanxi953.cn/posts/default/MySQL_For_Windows_Install</guid><dc:creator><![CDATA[元夕]]></dc:creator><pubDate>Mon, 03 Jun 2024 03:04:51 GMT</pubDate></item></channel></rss>