windows10安装MySQL5.7压缩免安装版

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32314965/article/details/85694024

首先在官网下载指定版本:https://dev.mysql.com/downloads/mysql/

下载压缩版的,解压到你指定的目录。目录结构为:

可以看到没有data目录和ini配置文件。这时新建my.ini,内容为

[mysqld]
port = 3306
basedir=D:\mysql-5.7.21-winx64
datadir=D:\mysql-5.7.21-winx64\data 
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
default-character-set=utf8

basedir是你解压的目录。

在系统变量中添加MYSQL_HOME

添加自己的解压目录的位置。

然后以管理员身份运行命令行界面后,跳转到你的文件目录位置,进入bin:

Microsoft Windows [版本 10.0.17134.472]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\WINDOWS\system32>d:

D:\>cd mysql-5.7.21-winx64

D:\mysql-5.7.21-winx64>bin
'bin' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

D:\mysql-5.7.21-winx64>cd bin

D:\mysql-5.7.21-winx64\bin>

运行命令mysqld --initialize --user=mysql --console

D:\mysql-5.7.21-winx64\bin>mysqld --initialize --user=mysql --console
2019-01-03T03:57:33.615250Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-03T03:57:33.615320Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2019-01-03T03:57:33.615325Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2019-01-03T03:57:41.305368Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-01-03T03:57:41.894574Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-01-03T03:57:42.090061Z 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: b832a04d-0f0b-11e9-b66b-68f72884c047.
2019-01-03T03:57:42.161239Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-01-03T03:57:42.184659Z 1 [Note] A temporary password is generated for root@localhost: l9BWVhuk45.y

 此时会初始化数据库,创建一个root账户并赋予一个初始密码l9BWVhuk45.y,一定记住这个临时密码。

D:\mysql-5.7.21-winx64\bin>mysqld install MySQL --defaults-file="D:\mysql-5.7.21-winx64\my.ini"

运行上述命令安装,引号中的文件地址改成自己的。

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


D:\mysql-5.7.21-winx64\bin>mysql -u root -p
Enter password:

然后输入net start mysql启动服务,启动成功后输入mysql -u root -p回车后输入上面的临时密码。(可能会报错说密码错误,注意多输入几次)

mysql> alter user user() identified by "!QAZ2wsx";
Query OK, 0 rows affected (0.00 sec)

mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> update mysql.user set authentication_string=password('!QAZ2wsx') where user='root' and Host ='localhost';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 进入后以此输入上述语句就可以将密码修改成功。

然后可以用可视化工具测试是否能连接成功。

猜你喜欢

转载自blog.csdn.net/qq_32314965/article/details/85694024
今日推荐