Mysql 5.7 Windows binary下载配置

本文以MySQL Community Server 5.7.34为例介绍MySQL数据库下载、安装、配置和基本操作。

一、MySQL5.7下载

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

选择 binary 版本

二、安装配置

本例安装位置:d:\mysql,选择你自己本的安装位置;

将下载的mysql解压到 d:\mysql\下,如: d:\mysql\mysql-5.7.34-winx64\,并在该目录下但也建 data 目录,及 my.ini 文件;

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 

[mysqld]

# 配置主从时,需要
server-id=1 

#设置3306端口
port = 3306 

# 设置mysql的安装目录
basedir=D:\\mysql\\mysql-5.7.34-winx64

# 设置mysql数据库的数据的存放目录
datadir=D:\\mysql\\mysql-5.7.34-winx64\\data

# 允许最大连接数
max_connections=200

# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8

# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

lower_case_table_names=1

# 2022-11-29 add
log-bin=log-bin
binlog-format=ROW

添加大小写敏感my.ini
lower_case_table_names=1

执行命令,运 行 mysql:

D:\mysql\mysql-5.7.34-winx64\bin>mysqld --defaults-file=D:\software\mysql-5.7.34-winx64\my.ini 
--initialize --user=mysql --console

命令输出:

2022-11-28T16:39:08.861951Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-11-28T16:39:09.028420Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-11-28T16:39:09.061160Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-11-28T16:39:09.167943Z 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: 2e774183-6f3b-11ed-8954-00ff1f00029c.
2022-11-28T16:39:09.173348Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-11-28T16:39:11.632345Z 0 [Warning] CA certificate ca.pem is self signed.
2022-11-28T16:39:11.976498Z 1 [Note] A temporary password is generated for root@localhost: Na<h4E8<ek+<

以上最后的”Na<****<” 为初始化的mysql用户密码,保存起来;
安装mysql服务:

D:\mysql\mysql-5.7.34-winx64\bin>mysqld --install MySQL --defaults-file="D:\software\mysql-5.7.34-winx64\my.ini"
Service successfully installed.

启动mysql:

D:\mysql\mysql-5.7.34-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

登录mysql修改密码,配置客户端可远程登录 :

D:\software\mysql-5.7.34-winx64\bin>mysql -uroot -p

输入上面初始化的密码;

> grant all privileges on *.* to ‘root’@’%’ identified by ‘xxxxxxx’; (提示应该使用 alter user 修改密码)

>alter user ‘root’@’localhost’ identified by ‘xxxxxxx’;

欢迎您的到来,感谢您的支持!

为您推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注