有事没事领个红包

win10搭建mysql5.7环境

下载mysql5.7

下载官网地址 https://downloads.mysql.com/archives/community/

解压到指定目录

我解压到 D:\Program Files\mysql-5.7.44

创建配置文件 my.ini

在上述目录中创建 my.ini 文件,并添加如下配置项

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
port = 3306
default-character-set=utf8
[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
character_set_server=utf8
init_connect='SET NAMES utf8'
basedir = D:\Program Files\mysql-5.7.44
datadir = D:\Program Files\mysql-5.7.44\data
port = 3306
default-storage-engine=INNODB
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

注意:

basedir = D:\Program Files\mysql-5.7.44 //这里改成你自己的安装目录
datadir = D:\Program Files\mysql-5.7.44\data //改成 安装目录\data 这个路径存放你的数据文件

配置环境变量

安装数据库服务

以管理员身份运行 cmd
执行以下命令
mysqld -install

数据库初始化

mysqld --defaults-file="D:/Program Files/mysql-5.7.44/my.ini" --initialize --console


红框内是产生的随机密码,把它记录下来。待会登录mysql要用。

启动数据库服务

net start mysql

登录并修改密码

mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';

参考资料
https://www.jianshu.com/p/ea4accd7afb4
https://www.cnblogs.com/f-society/p/6902057.html

posted @ 2024-02-25 12:04  crazyCodeLove  阅读(120)  评论(0编辑  收藏  举报