Windows下安装MySQL8.0详细教程-----请认真阅读里面的每一句话

Windows下安装MySQL8.0

 

1.下载安装包

mysql-8.0.20-winx64.zip

2.解压缩,配置环境变量

将mysql加入到系统path中(不多说)

E:\work\mysql-8.0.20\bin

3.新建配置文件

在安装目录下新建my.ini配置文件(E:\work\mysql-8.0.20\my.ini)

[mysqld]
#安装目录
basedir=E:\work\mysql-8.0.20
#data不要手动创建,初始化时 会自动创建
datadir=E:\work\mysql-8.0.20\data\
#端口
port=3306
#跳过密码验证,8.0以上版本开启会报错,所以不需要加下面命令
#skip-grant-tables

4.管理员模式下打开cmd,运行所有的命令

进入mysql安装目录下的bin目录:

C:\Users\Administrator>cd /d E:\work\mysql-8.0.20\bin

输入mysqld -install

E:\work\mysql-8.0.20\bin>mysqld -install
Service successfully installed.
#只有出现Service successfully installed.  才算注册服务成功

5.输入 mysqld --initialize-insecure --user=mysql 初始化数据文件

E:\work\mysql-8.0.20\bin>mysqld --initialize-insecure --user=mysql   --console
#执行完毕后,mysql安装目录下自动生成data文件夹
#执行完毕后,会给个临时密码,密码不一样相同(fkVQUk/ei7n,)
#A temporary password is generated for root@localhost: fkVQUk/ei7n,

6.启动mysql

E:\work\mysql-8.0.20\bin>net start mysql
MySQL 服务正在启动 ...
MySQL 服务已经启动成功。
#上述命令执行后,可在系统服务里看到MySql服务已经启动,正在运行

7.进入mysql

E:\work\mysql-8.0.20\bin>mysql -u root -p  # p后面一定不要加空格
Enter password: ************    #这个密码就是尚明生成的临时密码  fkVQUk/ei7n,
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.20
​
Copyright (c) 2000, 2020, 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.

8.修改密码

# 8.0以上版本修改密码 不能使用 update语句,必须使用alter  user ....
mysql> ALTER USER  'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.10 sec)
#刷新权限缓存
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)
#退出
mysql> exit;
Bye
  1. 重启mysql

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

    10.登陆测试

    E:\work\mysql-8.0.20\bin>mysql -u root -p  # -p后面一定不要加空格
    Enter password: ******     # 输入新的密码
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 9
    Server version: 8.0.20 MySQL Community Server - GPL
    ​
    Copyright (c) 2000, 2020, 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.
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值