IT评测·应用市场-qidao123.com技术社区

标题: win10安装mysql8 [打印本页]

作者: tsx81428    时间: 2025-4-14 16:09
标题: win10安装mysql8
win10安装mysql8

一、下载

从官网(传送门)下载zip文件放在安装位置,我放在D盘根目次了
地点: https://downloads.mysql.com/archives/community/
下载好之后解压,我的位置在 D:\mysql-8.0.34-winx64
二、修改设置

进入解压文件之后创建 my.ini文件 内容如下:
需要修改的位置basedir和datadir
datadir:数据库的数据的存放目次 我在安装目次创建了一个data,有其他需求的自己改
  1. [mysqld]
  2. # 设置3306端口
  3. port=3306
  4. # 设置mysql的安装目录
  5. basedir=D:\mysql-8.0.34-winx64
  6. # 设置mysql数据库的数据的存放目录
  7. datadir=D:\mysql-8.0.34-winx64\data  
  8. # 允许最大连接数
  9. max_connections=200
  10. # 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
  11. max_connect_errors=10
  12. # 服务端使用的字符集默认为UTF8
  13. character-set-server=utf8
  14. # 创建新表时将使用的默认存储引擎
  15. default-storage-engine=INNODB
  16. # 默认使用“mysql_native_password”插件认证
  17. default_authentication_plugin=mysql_native_password
  18. [mysql]
  19. # 设置mysql客户端默认字符集
  20. default-character-set=utf8
  21. [client]
  22. # 设置mysql客户端连接服务端时默认使用的端口
  23. port=3306
  24. default-character-set=utf8
复制代码
三、安装

管理员身份运行cmd
然后进入mysql安装目次下的bin文件夹(D:\mysql-8.0.34-winx64\bin)
1、输入:mysqld --initialize --console 下令初始化mysql
如果设置环境变量就没须要进入到bin目次了
  1. C:\WINDOWS\system32>D:
  2. D:\>cd D:\mysql-8.0.34-winx64\bin
  3. D:\mysql-8.0.34-winx64\bin>mysqld --initialize --console
  4. 2023-10-24T02:24:46.512711Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
  5. 2023-10-24T02:24:46.512743Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.34-winx64\bin\mysqld.exe (mysqld 8.0.34) initializing of server in progress as process 9292
  6. 2023-10-24T02:24:46.514743Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
  7. 2023-10-24T02:24:46.659221Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
  8. 2023-10-24T02:24:54.829085Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
  9. 2023-10-24T02:25:01.378161Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Qpf&Hqo2AwuY
  10. 2023-10-24T02:25:02.299377Z 6 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
  11. D:\mysql-8.0.34-winx64\bin>
复制代码
执行完 mysqld --initialize --console 下令后稍等一会 就会出现一个临时暗码 Qpf&Hqo2AwuY(备份一下,一会修改暗码需要用的一下)
[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Qpf&Hqo2AwuY
2、安装mysql服务
输入:mysqld  --install    下令
  1. D:\mysql-8.0.34-winx64\bin>mysqld  --install
  2. Service successfully installed.
复制代码
3、启动MySQL服务
输入:net start mysql   下令
  1. D:\mysql-8.0.34-winx64\bin>net start mysql
  2. MySQL 服务正在启动 ...
  3. MySQL 服务已经启动成功。
复制代码
4、进入mysql
输入:mysql -u root -p 下令,然后在输入刚刚天生的临时暗码
  1. D:\mysql-8.0.34-winx64\bin>mysql -u root -p
  2. Enter password: ************
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.
  4. Your MySQL connection id is 12
  5. Server version: 8.0.34
  6. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql>
复制代码
5、修改暗码
输入:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
  1. mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
  2. Query OK, 0 rows affected (0.15 sec)
  3. mysql>
复制代码
到这安装就竣事了
记得设置一下环境变量!

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 IT评测·应用市场-qidao123.com技术社区 (https://dis.qidao123.com/) Powered by Discuz! X3.4