Windows系统下Mysql的安装和使用

今天开始做数据库作业了,记得好久之前装过Mysql。不过用起来怪怪的,于是就重新装了一个,还配置了一个写SQL语句的IDE。记录一下过程~

1.下载Windows安装包

Windows(x86,64-bit) ZIP Archive

2.解压并添加环境变量

在这里插入图片描述

3.编辑配置文件

在这里插入图片描述

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\\MySQL\\mysql-8.0.15-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\MySQL\\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8

4.以管理员权限运行cmd并配置Mysql

C:\WINDOWS\system32>D:

D:\>cd MySQL

D:\MySQL>cd mysql-8.0.22-winx64

D:\MySQL\mysql-8.0.22-winx64>cd bin

D:\MySQL\mysql-8.0.22-winx64\bin>mysqld --install --console
Service successfully installed.

D:\MySQL\mysql-8.0.22-winx64\bin>mysqld --initialize --console
2020-11-23T05:57:53.185811Z 0 [System] [MY-013169] [Server] D:\MySQL\mysql-8.0.22-winx64\bin\mysqld.exe (mysqld 8.0.22) initializing of server in progress as process 56764
2020-11-23T05:57:53.185914Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'D:\MySQL\mysql-8.0.15-winx64\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2020-11-23T05:57:53.244784Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2020-11-23T05:57:53.336008Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-11-23T05:58:02.897378Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-11-23T05:58:24.423241Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: rBYJeMIr:4R?

5.启动Mysql服务

D:\MySQL\mysql-8.0.22-winx64\bin>net start mysql
服务名无效。

请键入 NET HELPMSG 2185 以获得更多的帮助。


D:\MySQL\mysql-8.0.22-winx64\bin>mysqld --install #注意把--console参数去掉
Service successfully installed.

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

net start mysql #启动服务

net stop mysql #停止服务

6.登录mysql

D:\MySQL\mysql-8.0.22-winx64\bin>mysql -u root -p
Enter password: ************(#初始密码:rBYJeMIr:4R?)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22

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.

mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';#修改密码为123456
Query OK, 0 rows affected (0.08 sec)

mysql>

百度盘链接:https://pan.baidu.com/s/1a1iqKH2OZ_L-5vdxjyrR0g
提取码:vvk1
IDE用的是Navicat Premium,免安装版本,感觉挺好用的。
最后致谢提供教程的大佬,blog传送门

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值