MySQL 5.7.17 for WIN8如何安装

34次阅读
没有评论

共计 2946 个字符,预计需要花费 8 分钟才能阅读完成。

这篇文章将为大家详细讲解有关 MySQL 5.7.17 for WIN8 如何安装,丸趣 TV 小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

1. 下载 MySQL Community Server 5.7.17, 注意选择系统类型(32 位 /64 位)

2. 解压缩 MySQL 压缩包到指定目录:

3. 添加环境变量
右键 – 我的电脑 – 属性 – 高级系统设置 – 环境变量
新建系统变量:
变量名:MYSQL_HOME
变量值:D:\database\mysql-5.7.17-winx64

再在 path 末尾中添加 %MYSQL_HOME%\bin
例如:
D:\Python27;C:\Users\duansf\Desktop\vim\vim80;%MYSQL_HOME%\bin

4. 注册为 windows 系统服务:
需要在命令提示符 (管理员模式) 下执行:

d:\database\mysql-5.7.17-winx64\bin d:\database\mysql-5.7.17-winx64\bin\mysqld install MySQL –defaults-file= d:\database\mysql-5.7.17-winx64\my.ini
Service successfully installed.

my.ini 内容如下:
[mysql]
# 设置 mysql 客户端默认字符集
default-character-set=utf8 
[mysqld]
# 设置 3306 端口
port = 3306 
# 设置 mysql 的安装目录
basedir=D:/database/mysql-5.7.17-winx64
# 设置 mysql 数据库的数据的存放目录
datadir=D:/database/mysql-5.7.17-winx64/data
slow_query_log=TRUE
slow_query_log_file=d:/slow_query_log.txt
long_query_time=1
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为 8 比特编码的 latin1 字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB 
# 主从复制参数配置
log_bin = mysql-bin
server_id = 1

5. 手动启动 MySQL 服务:
d:\database\mysql-5.7.17-winx64\bin net start mysql
MySQL 服务正在启动 ..
MySQL 服务无法启动。

服务没有报告任何错误。

请键入 NET HELPMSG 3534 以获得更多的帮助。

手动启动服务失败,经查看官方资料,解决思路如下:
启动前我们需要使用 -initialize 初始化 Data 目录生成并生成随机密码,使用 -initialize-insecure 可以生成空密码。默认帐号 root

此处我们用 -initialize-insecure 生成空密码

d:\database\mysql-5.7.17-winx64\bin mysqld –initialize-insecure

d:\database\mysql-5.7.17-winx64\bin net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。

用空密码登录:
C:\Users\duansf mysql -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.17-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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
mysql show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+——————–+
4 rows in set (0.00 sec)

mysql

6. 更改 root 密码:
mysql UPDATE mysql.user SET password=PASSWORD(123456) WHERE user= root
ERROR 1054 (42S22): Unknown column password in field list
mysql

更改密码报错,因为新版 5.7 版本的 mysql 数据库下的 user 表中已经没有 Password 字段了, 而是将加密后的用户密码存储于 authentication_string 字段
更改密码命令如下:

mysql update MySQL.user set authentication_string=password(123456) where user= root
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 1

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

7. 用新密码登录:
d:\database\mysql-5.7.17-winx64\bin mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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

关于“MySQL 5.7.17 for WIN8 如何安装”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-20发表,共计2946字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)