一、准备文件
mysql-5.7.21-winx64.zip一个;下载网址:https://dev.mysql.com/downloads/mysql/
二、安装文件
zip版是免安装的,将其解压到某个盘符下即可。这里解压到D盘;并配置环境变量path路径D:\mysql-5..21-winx64.zip\bin
三、配置文件
解压后,data目录(暂时不用管)和my.ini是没有的;
新建一个my.ini
内容配置如下:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\mysql\mysql-5.6.17-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\mysql\mysql-5.6.17-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
4. 安装服务
1. 以管理员身份进入dos窗口,然后切换到解压目录下。
2. 注册服务
D:\mysql-5.7.21-winx64\bin>mysqld -install
Service successfully installed.
3. 初始化
d:\mysql-5.7.21-winx64\bin>mysqld --initialize-insecure --user=mysql
4. 启动服务
d:\mysql-5.7.21-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
5.登录数据库(默认没有密码)
d:\mysql-5.7.21-winx64\bin>mysql -uroot -p
6.修改root密码
d:\mysql-5.7.21-winx64\bin>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.21 MySQL Community Server (GPL)
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> use mysql;
Database changed
mysql> update user set authentication_string=password("root") where User="root";
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)
mysql> \q
Bye
更新脚本:
mysql> update user set authentication_string=password("root") where User="root";