windows安装mysql5.7.md

windows安装mysql5.7

一、下载mysql安装包

下载地址
image-20220509173918892

二、解压到任意盘并重命名文件夹

image-20220509173930499

三、配置环境变量

变量名:MYSQL_HOME
变量值:Z:\MySQL\mysql-5.7.29
path里添加:%MYSQL_HOME%\bin
image-20220509173939042
image-20220509173948602

四、创建目录和配置文件

  • 在mysql-5.7.29目录下创建“data”文件夹和“my.ini”文件
    image-20220509173959974
  • 编辑“my.ini”文件内容如下(注意修改basedir,datadir的路径为你的解压盘符目录)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    [mysqld]
    port=3306
    character_set_server=utf8
    basedir=Z:\MySQL\mysql-5.7.29
    datadir=Z:\MySQL\mysql-5.7.29\data
    server-id=1
    sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    lower_case_table_names=1
    innodb_file_per_table = 1
    log_timestamps=SYSTEM

    log-error = error.log
    slow_query_log = 1
    slow_query_log_file = slow.log
    long_query_time = 5
    log-bin = binlog
    binlog_format = row
    expire_logs_days = 15
    log_bin_trust_function_creators = 1

    max_allowed_packet = 32M
    binlog_cache_size = 4M
    sort_buffer_size = 2M
    read_buffer_size = 4M
    join_buffer_size = 4M
    tmp_table_size = 96M
    max_heap_table_size = 96M
    lower_case_table_names=1
    innodb_file_per_table = 1


    [client]
    default-character-set=utf8

五、初始化数据库

1
2
3
4
// 管理员打开cmd命令,到bin目录下
cd Z:\MySQL\mysql-5.7.29\bin
//初始化
mysqld --initialize-insecure

六、注册并启动mysql服务

1
2
3
4
//cmd命令继续执行
mysqld –install
//启动mysql服务
net start mysql

image-20220509174037248

七、登录mysql并修改密码

1
2
3
4
5
6
7
8
//登录mysql
mysql -uroot
//修改密码
alter user 'root'@'localhost' identified by '你的密码'
//配置root用户远程连接。(无此需求可以不执行)
GRANT ALL PRIVILEGES ON *.* TO 'ROOT'@'%' IDENTIFIED BY 'HBQ521521CF*' WITH GRANT OPTION;
//刷新权限
flush privileges;

image-20220509174045490

八、重新连接数据库或使用navicat连接

mysql -uroot -p你的新密码
image-20220509174053979
image-20220509174101579


windows安装mysql5.7.md
http://example.com/4135.html
作者
John Doe
发布于
2022年9月7日
许可协议