下载mysql解压版
1. 官网(https://dev.mysql.com/downloads/mysql/5.7.html)下载mysql5.7.34,选择zip;
2. 解压目录的C盘;
3. 在目录下添加data文件夹,文件夹为空;添加my.ini文件,文件内容如下;
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\\mysql-5.7.34-winx64
datadir=C:\\mysql-5.7.34-winx64\\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
innodb_flush_method=normal
[client]
#设置3306端口
port = 3306
4.把my.ini 复制一份到 mysql解压目录\bin 下。
5.执行两条命令,执行后在运行服务,在修改密码。
mysqld --install
输出
Service successfully installed.
执行
mysqld --initialize --user=mysql --console
输出
2021-07-12T01:47:52.606355Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-07-12T01:47:54.324254Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-07-12T01:47:54.732851Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-07-12T01:47:54.906847Z 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: 2d209279-e2b3-11eb-b73f-80fa5b3c8327.
2021-07-12T01:47:54.935343Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-07-12T01:47:57.595813Z 0 [Warning] CA certificate ca.pem is self signed.
2021-07-12T01:47:58.242564Z 1 [Note] A temporary password is generated for root@localhost: qlgdgMJ6Vu>!
2021-07-12T01:48:04.117674Z 0 [Warning] CTRL-C ignored during startup
2021-07-12T01:48:04.317683Z 0 [Warning] CTRL-C ignored during startup
其中 qlgdgMJ6Vu>! 是新mysql的密码
在连接mysql服务,更改密码
mysql -uroot -p
粘贴进去生成的密码
修改新密码为123456
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
连接成功
如果出现丢失 MSVCR120.dll 的情况
下载安装补丁安装就可以了
下载地址:
http://download.microsoft.com/download/b/e/8/be8a5444-cdd8-4d3d-ae09-a0979b05aee3/vcredist_x64.exe
下载后双击运行,安装后修复 MSVCR120.dll 问题