本地已经安装过mysql5.1版本,应项目需求需要安装mysql5.7版本;
官方网站下载对应版本:https://downloads.mysql.com/archives/community/
压缩包下载完成后解压至本地磁盘,使用CMD命令行进入根目录下bin文件夹,进行初始化:
D:\mysql-5.7.28\bin>mysqld --initialize --console
2020-03-23T07:44:37.456510Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-03-23T07:44:40.977510Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-03-23T07:44:41.697510Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-03-23T07:44:41.917510Z 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: 28112793-6cda-11ea-aed0-00ff8f89dfb9.
2020-03-23T07:44:41.982510Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-03-23T07:44:43.960510Z 0 [Warning] CA certificate ca.pem is self signed.
2020-03-23T07:44:45.424510Z 1 [Note] A temporary password is generated for root@localhost: rr(epW#zd0wJ
初始化成功后创建my.ini配置文件。
[client]
port=3309
default-character-set=utf8
[mysqld]
#设置3309端口
port=3309
#设置mysql的安装目录
basedir=D:\mysql-5.7.28
#设置mysql数据库的数据的存放目录
datadir=D:\mysql-5.7.28\data
#允许最大连接数
max_connections=200
#许连接失败的次数
max_connect_errors=10
#服务端使用的字符集默认为UTF8
character-set-server=utf8
#建新表时将使用的默认存储引擎
default-storage-engine=INNODB
#默认使用“mysql_native_password”
default_authentication_plugin=mysql_native_password
#设置是否自动提交(0=off/1=on),关闭状态insert,delete,update后如果不commit可以进行rollback
autocommit=0
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
进行服务安装,由于之前安装过一个低版本mysql,本次服务命名为mysql2。
D:\mysql-5.7.28\bin>mysqld -install mysql2 --defaults-file="D:\mysql-5.7.28\my.ini"
Service successfully installed.
修改注册表:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\mysql2,修改ImagePath参数值:修改成本次安装路径的bin目录即可,如果未修改该部分内容可能导致服务启动出现1067错误。
启动服务器即可:
bin>net start mysql2
mysql2 服务正在启动 .
mysql2 服务已经启动成功。