Windows安装mysql-5.7.28

1 MySQL下载。

下载链接:https://downloads.mysql.com/archives/community/

2 安装过程。

2.1 解压到指定路径。

2.2 添加环境变量。

2.3 新建my.ini配置文件。

[mysqld]
basedir=E:\mysql-5.7.28\
datadir=E:\mysql-5.7.28\data\
port=3306
skip-grant-tables

2.4 管理员模式启用cmd,安装MySQL服务。

C:\Windows\system32>cd /d E:\mysql-5.7.28\bin
E:\mysql-5.7.28\bin>mysqld -install
Service successfully installed.

2.5 初始化数据库文件。

E:\mysql-5.7.28\bin>mysqld --initialize-insecure --user=mysql

2.6 启动数据库。

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

2.7 连接MySQL数据库。

E:\mysql-5.7.28\bin>mysql -u root -p
Enter password:  #无需输入密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 MySQL Community Server (GPL)

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

2.8 修改密码。

mysql> update mysql.user set authentication_string=password('123456') where user='root' and host='localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> select user,host,authentication_string from mysql.user;
+---------------+-----------+-------------------------------------------+
| user          | host      | authentication_string                     |
+---------------+-----------+-------------------------------------------+
| root          | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys     | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+---------------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)

2.9 刷新权限。

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

2.10 注释my.ini。

[mysqld]
basedir=E:\mysql-5.7.28\
datadir=E:\mysql-5.7.28\data\
port=3306
#skip-grant-tables

2.11 重启服务。

mysql> exit
Bye
E:\mysql-5.7.28\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
E:\mysql-5.7.28\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

2.12 重新连接。

E:\mysql-5.7.28\bin>mysql -u root -p
Enter password: ******  #需要密码连接
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值