一、MySQL的Windows系统安装
1、下载MySQL安装包
打开如下链接地址,下载安装包
2、安装并配置
双击下载好的安装包进行安装,出现如下界面:
![](https://img-blog.csdnimg.cn/direct/3dba7b9a88c8464283b5dfd10d2779a3.png)
选择【 Full 】选项,然后单击【 Next 】按钮。
![](https://img-blog.csdnimg.cn/direct/a6c7c5d703b24f12a71802958041c267.png)
出现如下界面,单击【 Execute 】按钮
![](https://img-blog.csdnimg.cn/direct/307b96b22f914e98b87ecb92457d8b59.png)
下一步执行完成后,会出现以下界面,单击【 Next 】按钮。
![](https://img-blog.csdnimg.cn/direct/1cedccd32d354f75980f30bf913e2e05.png)
执行后,会跳转到如下界面:然后单击【 Next 】按钮进行下一步
![](https://img-blog.csdnimg.cn/direct/34d6d68f68654ab2a46b43eb56eba2d4.png)
跳转到如下界面,单击【 Next 】按钮进行下一步。
![](https://img-blog.csdnimg.cn/direct/886de5878aea4052827ddf1dca215d9a.png)
![](https://img-blog.csdnimg.cn/direct/6b2f2aca0fdf469d91334ef42e8c2cc5.png)
跳转到以下界面,单击【 Next 】进行下一步。
![](https://img-blog.csdnimg.cn/direct/35a0af2711e14d8d9db01c3157467fb9.png)
跳转到如下界面,单击【 Next 】按钮进行下一步
![](https://img-blog.csdnimg.cn/direct/de00a741eb794942b0295e50d82c52ea.png)
跳转到以下界面,单击【 Execute 】执行安装。
![](https://img-blog.csdnimg.cn/direct/3c1280e74a2b478290a54e786f23dc80.png)
安装完成后,跳转到如下界面:单击【 Finish 】按钮完成安装。
![](https://img-blog.csdnimg.cn/direct/57ebfd220ab146b783646b352c9fba39.png)
跳转到如下界面,接下来进行软件相关配置,单击【 Next 】按钮进行下一步
![](https://img-blog.csdnimg.cn/direct/07b2e8c201f149ae93a2efff21f626dc.png)
跳转到如下界面,直接单击【 Finish 】按钮。
![](https://img-blog.csdnimg.cn/direct/38aef8df7b524782a55ab16e030c2688.png)
跳转到如下界面,单击【 Finish 】按钮进行下一步。
![](https://img-blog.csdnimg.cn/direct/3b903ae4d02746bca995e23ed0c5d820.png)
跳转到如下界面,在【 Password 】窗口输入前面填写的密码,然后单击【 Check 】按钮,当出现绿色对勾提示的时候,说明密码测试没有问题。单击【Next 】按钮进行下一步。
![](https://img-blog.csdnimg.cn/direct/df2c215837374fb6b322dc1a9303f133.png)
跳转到如下界面,单击【 Execute 】按钮进行下一步。
![](https://img-blog.csdnimg.cn/direct/6e25e7793e02444eb5be6e8b04326a8d.png)
执行完成之后如下图所示:单击【 Finish 】按钮 i 进行下一步
![](https://img-blog.csdnimg.cn/direct/145e5763f5404b3d9703ab671d0d2762.png)
跳转到如下界面,单击【 Next 】按钮进行下一步。
![](https://img-blog.csdnimg.cn/direct/13db859ad69841f3a24c0472a4b7312c.png)
跳转到如下界面,取消两个复选框的勾选。然后单击【 Finish 】按钮进行下一步
![](https://img-blog.csdnimg.cn/direct/a374fc785d344c938273cccc6699e409.png)
3、后续的配置
3.1、配置客户端字符配置文件
找到 C:\Program Files\MySQL\MySQL Workbench 8.0\workbench 目录下的 os_utils.py 文件,使用
notepad++ 软件打开进行编辑。
找到 356 行,将字符集 utf-8 修改为 gbk 即可。
![](https://img-blog.csdnimg.cn/direct/077a2cfe22874d269903f43cc2326395.png)
二、创建一个英雄表(hero)
主键、name、nickname、address、groups、email、telphone
1、登录数据库
[root@localhost ~]# mysql -uroot -pAdmin123!
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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.
mysql8.0 [(none)]>
2、创建数据库并使用
mysql8.0 [(none)]>create database db_test;
Query OK, 1 row affected (0.00 sec)
mysql8.0 [(none)]>use db_test;
Database changed
mysql8.0 [db_test]>
3、创建表hero
mysql8.0 [db_test]>create table hero( id int auto_increment primary key, name varchar(255) not null, nickname varchar(255), address varrchar(255), group_ varchar(255), email varchar(255), telephone int );
Query OK, 0 rows affected (0.01 sec)
4、向表中添加数据
mysql8.0 [db_test]>insert into hero (name,nickname,address,group_,email,telephone)
-> values
-> ('孙悟空','齐天大圣','花果山','西天取经','232131@qq.com',1234322342),
-> ('唐玄奘','唐僧','长安','西天取经','12321312@qq.com',2132132112),
-> ('曹孟德','曹操','许昌','魏国','1231221@qq.com',2132131212),
-> ('诸葛亮','孔明先生','襄樊','蜀国','3213213@qq.com',1231231233);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
5、查看表结构
mysql8.0 [db_test]>desc hero;
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
| nickname | varchar(255) | YES | | NULL | |
| address | varchar(255) | YES | | NULL | |
| group_ | varchar(255) | YES | | NULL | |
| email | varchar(255) | YES | | NULL | |
| telephone | int(11) | YES | | NULL | |
+-----------+--------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)
mysql8.0 [db_test]>
6、查看表的数据
mysql8.0 [db_test]>select * from hero;
+----+-----------+--------------+-----------+--------------+-----------------+------------+
| id | name | nickname | address | group_ | email | telephone |
+----+-----------+--------------+-----------+--------------+-----------------+------------+
| 1 | 孙悟空 | 齐天大圣 | 花果山 | 西天取经 | 232131@qq.com | 1234322342 |
| 2 | 唐玄奘 | 唐僧 | 长安 | 西天取经 | 12321312@qq.com | 213213212 |
| 3 | 曹孟德 | 曹操 | 许昌 | 魏国 | 1231221@qq.com | 2132131212 |
| 4 | 诸葛亮 | 孔明先生 | 襄樊 | 蜀国 | 3213213@qq.com | 123123123 |
+----+-----------+--------------+-----------+--------------+-----------------+------------+
4 rows in set (0.00 sec)
mysql8.0 [db_test]>