windows安装MYSQL5.7
在Windows系统下安装MySQL 5.7的步骤如下:
步骤1:下载MySQL 5.7
- 打开浏览器并访问MySQL下载页面。
https://downloads.mysql.com/archives/community/
- 选择“Windows (x86, 64-bit), ZIP Archive”或“MySQL Installer for Windows”下载。当前版本是
mysql-5.7.44-winx64.zip
- 点击“Download”,在跳转页面中可以选择“No thanks, just start my download.”来直接下载。
步骤2:解压安装程序
- zip文件windows10以上操作系统可以直接解压 另外可以使用其他压缩工具解压
假定你解压的路径是
D:\mysql-5.7.44-winx64
步骤3:配置环境变量
- 右键点击“计算机”或“此电脑”,选择“属性”。
- 点击“高级系统设置”,然后点击“环境变量”。
- 新增一个环境变量
MYSQL_HOME=D:\mysql-5.7.44-winx64
- 在“系统变量”部分,找到并选中
Path
,点击“编辑”。 - 在“编辑环境变量”窗口中,点击“新建”,添加MySQL的bin目录路径。
%MYSQL_HOME%\bin;
- 点击“确定”保存并退出所有窗口。
步骤4:新建配置文件 my.ini
MYSQL配置文件参考
# 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]
default-character-set=utf8
[mysqld]
character-set-server=utf8
default-storage-engine=INNODB
#lower_case_table_names=1
log_bin_trust_function_creators=1
# 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.
basedir = D:\mysql-5.7.44-winx64
datadir = D:\mysql-5.7.44-winx64\data
port = 3306
character-set-server=utf8
character-set-filesystem = utf8
# 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
步骤5:安装MYSQL
- 打开命令提示符(按
Win+R
,输入cmd
并回车)。 - 输入以下命令连接到MySQL服务器:
mysqld --initialize --user=mysql --console
# 安装
mysqld --install mysql
# 卸载
mysqld -remove
# 启动服务
net start mysql
# 停止服务
net stop mysql
- 命令行进入
mysql -u root -p
- 成功连接后,修改密码:
mysql>update mysql.user set authentication_string=password('123456') where user='root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql> flush privileges;