windows安装mysql8(5分钟)
1、下载 MySQL
https://dev.mysql.com/downloads/mysql/
下载完成后,解压缩到你的目录里。
2、配置 MySQL 的配置文件
创建一个文件,名称为:my.ini,使用记事本打开,输入以下内容
[client]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\SoftWare\Local\Work\mysql-8.0.29-winx64
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=C:\\web\\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
3、初始化数据库
使用管理员权限打开 cmd,来到 mysql 安装目录下的 bin 目录里:
输入命令:mysqld --initialize --console
D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin>mysqld --initialize --console
2022-07-06T08:38:31.781340Z 0 [System] [MY-013169] [Server] D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin\mysqld.exe (mysqld 8.0.29) initializing of server in progress as process 18088
2022-07-06T08:38:31.796289Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-07-06T08:38:32.132148Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-07-06T08:38:33.130450Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pn!gQVVuk8(a
pn!gQVVuk8(a
就是默认生成的密码。
4、安装 mysqld
输入命令:mysqld install
D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin>mysqld install
Service successfully installed.
5、启动 mysql
输入命令:net start mysql
D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
6、登录 mysql
输入命令:mysql -u root -p
再输入刚刚mysql默认生成的密码:** **pn!gQVVuk8(a
D:\SoftWare\Local\Work\mysql-8.0.29-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.29
Copyright (c) 2000, 2022, 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 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER user 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.01 sec)
mysql>
7、修改密码
mysql8+修改密码命令: ALTERuser'root'@'localhost' IDENTIFIED BY'root'
本文作者:fengzeng
本文链接:https://www.cnblogs.com/Fzeng/p/16451530.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律