Win10下mysql 8.0.20 安装配置

一、MYSQL下载
选择国内的镜像,官方网站太慢了!可以使用sohu的镜像:http://mirrors.sohu.com/mysql/MySQL-8.0/在这里插入图片描述
二、解压与配置
将下载的压缩包解压到D盘全英文文件夹下,如:在这里插入图片描述
安装与配置:
第一步,在解压的文件夹建立my.ini文件,例如:d:\software\mysql。有一点必须注意,创建文件时必须选择显示文件扩展名,将默认的txt去掉!在这里插入图片描述
文件中添加以下内容:

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\\software\\mysql
# 设置mysql数据库的数据的存放目录
datadir="D:\\software\\mysql\\data"
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

lc-messages-dir=D:\\software\\mysql\\share

第二步,以管理员权限打开cmd,切换到mysql文件夹内的bin文件夹下,如d:\software\mysql\bin
在这里插入图片描述
分步输入以下命令:
输入mysqld --install(如果需要安装多个mysql服务,输入mysqld --install [服务名])

D:\software\mysql\bin>mysqld --install
Service successfully installed.

输入mysqld --initialize --console,进行初始化。该步可以得到mysql的初始密码,root@localhost后面那一串就是初始密码,先记录下来,待会要用到

D:\software\mysql\bin>mysqld --initialize --console
2021-01-13T12:50:25.532155Z 0 [System] [MY-013169] [Server] D:\software\mysql\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 8144
2021-01-13T12:50:29.611322Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 2eL,-7ve0Ya!
2021-01-13T12:50:31.129063Z 0 [System] [MY-013170] [Server] D:\software\mysql\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed

输入net start mysql,启动MySQL服务

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

第三步,登录mysql,并修改初始密码。
输入mysql -u root -p,使用初始密码登录mysql,在Enter password后输入初始密码

D:\software\mysql\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11

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.

登录后,把初始密码修改掉,可以设置成自己容易记住的密码。
输入ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘自己定义的密码’; (分号一定要带)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'hsm6786092'
    -> ;
Query OK, 0 rows affected (0.04 sec)

输入show databases; ,可以查看包含哪些数据表

mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

第四步,然后把mysql所在的路径添加到环境变量Path中
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值