一、下载免安装压缩包
二、本地环境配置
- 把zip包解压到需要安装的目录 ,会发现缺少data文件夹以及my.ini的配置文件
2.添加data文件夹以及my.ini环境配置
3. my.ini文件中添入一下内容并修改下面两项
basedir = F:/soft/mysql-5.7.25 是你解压之后的根目录
datadir = F:/soft/mysql-5.7.25/data 是你解压之后的根目录下的data
注意:要是 / 而不是
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/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. [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的缓存,可以根据实际情况调整大小,我这里采取默认值 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. #mysql根目录 basedir = F:/soft/mysql-5.7.25 #数据存储目录 datadir = F:/soft/mysql-5.7.25/data #端口号,默认为3306 port = 3306 #服务实例的唯一标识,这个是做集群的时候使用,单例可以不配置 # 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 #配置一下服务端的字符集 character_set_server=utf8mb4 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #配置一下客户端的字符集 [client] default-character-set=utf8mb4
4.初始化数据库 以管理员身份运行cmd 进入到bin目录下
mysqld --initialize 执行完成之后会在data下生成一些文件
5.注册为windows服务
mysqld --install MySQL57 #install后面是服务的名字,我们这里以MySQL57作为mysql5.7的服务名
6.启动mysql 登录并修改密码
mysql -u root -p
这次的登录密码并不是空,而是在data文件夹下有一个.err结尾的文件,如下图所示
找到之后可以正常登录。
7.修改密码并刷新 分号保留 修改成功之后可以正常登录
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘123456’;
FLUSH PRIVILEGES;