温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

MySQL 5.7.17 for WIN8如何安装

发布时间:2021-11-11 13:56:45 来源:亿速云 阅读:167 作者:小新 栏目:MySQL数据库

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

1. 下载MySQL Community Server 5.7.17,注意选择系统类型(32位/64位)
MySQL 5.7.17 for WIN8如何安装


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

MySQL 5.7.17 for WIN8如何安装

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如何安装”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI