下载mysql5
https://dev.mysql.com/downloads/mysql/5.7.html
解压后配置在bin目录下新建my.ini
[client]
port=3306
default-character-set=utf8
[mysqld]
# 设置为自己MYSQL的安装目录
basedir=E:\mysql-5.7.37-winx64
# 设置为MYSQL的数据目录
datadir=E:\mysql-5.7.37-winx64\data
port=3306
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
#开启查询缓存
explicit_defaults_for_timestamp=true
skip-grant-tables
#默认引擎
default-storage-engine=InnoDB
bin目录下安装mysql服务
E:\mysql-5.7.37-winx64\bin>mysqld --install
Service successfully installed.
初始化
E:\mysql-5.7.37-winx64\bin>mysqld --initialize --user=mysql --console
2022-03-06T03:11:29.779648Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-03-06T03:11:30.245461Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-03-06T03:11:30.340438Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-03-06T03:11:30.433731Z 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: 1e83f839-9cfb-11ec-b4a7-b025aa276450.
2022-03-06T03:11:30.438899Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-03-06T03:11:33.411394Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-03-06T03:11:33.411780Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-03-06T03:11:33.418555Z 0 [Warning] CA certificate ca.pem is self signed.
2022-03-06T03:11:34.183312Z 1 [Note] A temporary password is generated for root@localhost: Xet:dujLB1go
启动服务
E:\mysql-5.7.37-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
修改密码
E:\mysql-5.7.37-winx64\bin>mysql -u root -p
#密码为之前初始化生成密码
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.37
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> set password for 'root'@'localhost' = password('');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>