下载地址
https://dev.mysql.com/downloads/mysql/
解压文件到自定义目录
编辑my.ini文件
在mysql根目录下(E:\dev_env\mysql-5.7.31-winx64)生成my.ini文件
内容如下:
[client]
default-character-set=utf8mb4
[mysqld]
port = 3306
basedir=E:\\dev_env\\mysql-5.7.31-winx64
datadir=E:\\dev_env\\mysql-5.7.31-winx64\\data
character-set-server=utf8mb4
default-storage-engine=innoDB
初始化数据库
以管理员的方式进入mysql根目录下的bin目录,执行如下命令:
mysqld --initialize
执行完以上命令,mysql在根目录下生成data目录,进入data目录,查看xxx.err文件(xxx根据具体的机器进行命名)
2020-08-13T06:47:08.326725Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-08-13T06:47:08.867306Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-08-13T06:47:08.916167Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-08-13T06:47:09.022099Z 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: cf0df0bc-dd30-11ea-bdb8-005056c00001.
2020-08-13T06:47:09.041701Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-08-13T06:47:10.676745Z 0 [Warning] CA certificate ca.pem is self signed.
2020-08-13T06:47:11.057515Z 1 [Note] A temporary password is generated for root@localhost: GrvhI,FSx9/z
上面日志中,root@localhost:后面的即为初始密码
安装mysql服务
mysqld install
启动mysql
net start mysql
修改初始密码
运行如下命令登录mysql
mysql -uroot -p
执行如下命令修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';