MySQL 官方参考手册:https://dev.mysql.com/doc/refman/5.7/en/installing.html
- 步骤一:下载 MySQL Installer(适用于Windows),并让它安装和配置系统上的所有 MySQL 产品。
下载地址:https://dev.mysql.com/downloads/installer/
- 步骤二:双击运行 mysql-installer-community-5.7.24.0.msi
- 步骤三:这里我选择自定义(Custom),也可以选择 Developer Default 安装默认的所有文件
- 步骤四:选择只安装 MySQL Server 5.7.24-X64,将其移动到右边,点击Next
- 步骤五:设置 root 用户的密码,同时可以通过 add user 添加用户
- 步骤六:设置 mysql 服务的名称,这里我用默认
说明:
Ⅰ、安装完成 mysql 之后,默认 mysql 安装在: C:\Program Files\MySQL\MySQL Server 5.7
- bin:存储可执行文件
- include:存储包含的头文件
- lib:存储库文件
- share:错误信息和字符集文件
Ⅱ、默认数据存放文件以及 my.ini 的配置文件在: C:\ProgramData\MySQL\MySQL Server 5.7
Ⅲ、mysql 的配置文件为 my.ini 文件
[client]
# 指定客户端从3306端口进入
# pipe=
# socket=MYSQL
port=3306
[mysql]
# 指定客户端的默认字符集
no-beep
default-character-set=utf8
[mysqld]
# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipe
# shared-memory
# shared-memory-base-name=MYSQL
# The Pipe the MySQL Server will use
# socket=MYSQL
# 设置服务端的端口号
# The TCP/IP Port the MySQL Server will listen on
port=3306
# 指定mysql的安装路径
# Path to installation directory. All paths are usually resolved relative to this.
# basedir="C:/Program Files/MySQL/MySQL Server 5.7/"
# 指定数据的存放路径
# Path to the database root
datadir=C:/ProgramData/MySQL/MySQL Server 5.7/Data
# 指定服务端使用的默认字符集
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
# 指定创建新表使用的默认存储引擎
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB
......
Ⅳ、重启 mysql 服务
Ⅴ、配置环境变量
配置 MYSQL_HOME
配置 path ,添加:
或者添加:
Ⅵ、测试
C:\Users\ys951>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.24-log MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
Ⅶ、也可以使用官方的可视化工具以及第三方的可视化工具操作数据库
在安装 mysql 的时候将 workbench 工具也选中进行安装