1,安装版本:
mysql-5.7.39-winx64
2,my.ini文件:
basedir 必须注释掉,否会有错误:错误内容为:
Can't find error-message file 'D:\mysql\mysql\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive
my.ini文件内容:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
# basedir=D:\\mysql\\mysql
# 设置mysql数据库的数据的存放目录
datadir=D:\\mysql\\mysql\\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
skip-grant-tables
3.1,初始化数据(注意目录)
2023-01-07T08:15:14.394296Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-01-07T08:15:14.576592Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-01-07T08:15:14.620302Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-01-07T08:15:14.709317Z 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: 69d90a5d-8e63-11ed-9236-98fa9bbcb275.
2023-01-07T08:15:14.713545Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-01-07T08:15:15.508274Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-01-07T08:15:15.508557Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-01-07T08:15:15.511399Z 0 [Warning] CA certificate ca.pem is self signed.
2023-01-07T08:15:15.784901Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
4,启动mysql,修改root密码
启动之前修改my.ini文件,注释掉最后一行:
# skip-grant-tables
启动命令(进入对应目录):
mysqld --console
5,添加mysql到服务(可不添加到服务)
mysqld -install