MySQL 5.7.17 绿色版 如何安装

时间:2020-12-01 16:32:19

注意:我对转载文章进行了修改!!!

原文地址:http://www.cnblogs.com/lol-ashe/p/6371072.html


MySQL5.7.17绿色版安装

1、下载mysql5.7.1的zip包https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-win32.zip;

2、【我没有设置!】设置环境变量:新建变量MySQL_HOME,变量值C:\mysql-5.7.17-winx64;path增加变量,&MySQL_HOME&\bin;

3、把my-default.ini复制出一份命名为my.ini

修改 [mysqld]块

[mysqld]
basedir = D:\MySQL\mysql-5.7.17-win32
datadir = D:\MySQL\mysql-5.7.17-win32\mydata(我自己建的)
port = 3306

新增新配置

[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8

4、【用管理员权限!】cmd进入mysql\bin目录下,执行mysqld --initialize-insecure --user=mysql初始化data目录,

然后执行mysqld -install安装成服务,如果之前有安装过,则先卸载(mysqld -remove)后再执行安装;

5、启动服务:net start mysql;或者通过右键计算机-管理-服务,找到MYSQL开启,设置成自动;

6、mysql -uroot -p 无密码进入

7、改密码:SET PASSWORD = '(密码)';

=======================================================================

第4~7步,执行如下:

d:\MySQL\mysql-5.7.17-win32\bin>mysqld --initialize-insecure --user=mysql


d:\MySQL\mysql-5.7.17-win32\bin>mysqld -install
Service successfully installed.


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




d:\MySQL\mysql-5.7.17-win32\bin>mysql -uroot -p
Enter password:  【直接回车】
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17 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> set password='lanman';
Query OK, 0 rows affected (0.00 sec)


mysql> exit
Bye


d:\MySQL\mysql-5.7.17-win32\bin>mysql -uroot -p
Enter password:【此处回车,显示下行错误】
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


至此完成配置,后续正常使用数据库