概述
1 下载mysql
这里使用的是mysql-5.7.21-winx64.zip
2 解压mysql
笔者这里解压到E盘下,解压后的路径是E:mysql-5.7.21-winx64
3 安装说明
创建在mysql的目录下创建my.ini文件,路径为E:mysql-5.7.21-winx64my.ini,内容如下:
[mysql]
default-character-set=utf8
[mysqld]
port=3307
#basedir=../
basedir=E:mysql-5.7.21-winx64
#datadir=../data
datadir=E:mysql-5.7.21-winx64data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
mysql的默认端口是3306,笔者这里修改成3307,如上port=3307所示,读者可自行修改
打开命令窗口cmd,执行初始化命令
e:
cd mysql-5.7.21-winx64
cd bin
mysqld.exe --defaults-file=../my.ini --initialize --console
执行完上面命令后,可能出现以下问题:
由于找不到MSVCR120.dll,无法继续执行代码。重新安装程序可能会解决问题此时需要下载vcredist_x64.exe进行安装即可,可通过百度网盘下载,或者自行到微软官网下载安装,然后重新执行上述命令
执行完上面命令后,将会出现如下提示:
2019-10-23T04:47:32.733245Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-23T04:47:32.733341Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2019-10-23T04:47:32.739966Z 0 [Warning] You need to use --log-bin to make --binlog-format work.
2019-10-23T04:47:41.477417Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-10-23T04:47:42.722552Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-10-23T04:47:43.016668Z 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: 3fec7ca2-f550-11e9-971a-206a8ad9ac7d.
2019-10-23T04:47:43.130306Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-10-23T04:47:43.161712Z 1 [Note] A temporary password is generated for root@localhost: fC*_qA+u&4ar
上面提示中fC*_qA+u&4ar为root的临时密码,需要将此密码记录下,后面root用户需要这个密码进行登录
启动mysql
在之前的命令窗口cmd中输入以下命令(如果之前的命令窗口被关闭,那么需要重新打开一个命令窗口cmd,然后切换到mysql的bin目录下):
mysqld.exe --defaults-file=../my.ini --console
在cmd窗口中输入上面语句后,输出内容部分如下所示:
2019-10-23T06:15:57.961191Z 0 [Note] Server hostname (bind-address): '*'; port: 3307
2019-10-23T06:15:57.964441Z 0 [Note] IPv6 is available.
2019-10-23T06:15:57.965497Z 0 [Note] - '::' resolves to '::';
2019-10-23T06:15:57.966595Z 0 [Note] Server socket created on IP: '::'.
2019-10-23T06:15:58.067633Z 0 [Note] InnoDB: Buffer pool(s) load completed at 191023 14:15:58
2019-10-23T06:15:58.183228Z 0 [Note] Event Scheduler: Loaded 0 events
2019-10-23T06:15:58.184274Z 0 [Note] mysqld.exe: ready for connections.
Version: '5.7.21' socket: '' port: 3307 MySQL Community Server (GPL)
如上出现mysqld.exe: ready for connections.则表明mysql启动成功。
使用root用户登录
重新打开一个新的命令行窗口
在新的命令行窗口中切换到mysql的bin目录下,具体命令如下:
e:
cd mysql-5.7.21-winx64
cd bin
mysql.exe -P 3307 -u root -p
输入上面命令后,出现提示Enter password:要求输入密码,此时输入上述的root的临时密码fC*_qA+u&4ar
输入完成后,会出现如下提示:
E:mysql-5.7.21-winx64bin>mysql.exe -P 3307 -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.21
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>
出现以上提示,则表明root用户登录成功
修改root用户密码
root用户登录成功后,直接再输入以下命令:
set password = password('root');
password('root')中的root为root用户的新密码,读者根据需求自行修改,输入上述命令后提示如下:
mysql> set password = password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
修改完成后,可以输入q;退出mysql命令窗口
4 将mysql安装成系统服务
使用以下命令进行安装:
e:
cd mysql-5.7.21-winx64
cd bin
mysqld.exe --install mysql57
按回车执行后,如果出现Install/Remove of the Service Denied!提示,则需要使用管理员身份打开cmd命令行窗口,然后再重新输入上面命令,成功后会出现Service successfully installed.提示
安装完成后,打开系统服务,可以找到名称为mysql57的服务,然后再根据情况修改启动类型。如果需要随系统自动启动,将启动类型修改成“自动”即可
也可以在命令行窗口cmd中输入命令启动服务:
net start mysql57
执行完上面命令后出现如下提示,表明服务启动成功:
E:mysql-5.7.21-winx64bin>net start mysql57
mysql57 服务正在启动 ...
mysql57 服务已经启动成功。
E:mysql-5.7.21-winx64bin>
附:
使用服务命令启动mysql
启动net start mysql57
停止net stop mysql57
最后
以上就是开放钢笔为你收集整理的mysql压缩版 windows安装,Windows安装mysql压缩版本的全部内容,希望文章能够帮你解决mysql压缩版 windows安装,Windows安装mysql压缩版本所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复