数据库(MySQL)在Windows系统的安装

一、MySQL在Windows系统的安装

1、在MySQL :: Download MySQL Installer下载安装包

2、安装并配置

<1>
<2>

<3>

<4>

<5>

<6>

<7>

<8>

<9>

<10>

<11>

<12>

<13>

<14>

<15>

<16>

<17>

<18>

<19>

3、MySQL安装后再Windows上的操作

(1)配置字符配置文件

 C:Program FilesMySQLMySQL Workbench 8.0workbench 目录下的 os_utils.py 文件,使用
notepad++ 软件打开进行编辑。
找到  356 行,将字符集 utf-8 修改为 gbk 即可。
 

二、创建一个hero表

主键、name、nickname、adress、groups、email、telphone

(1)登录数据库

[root@zyw ~]# 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)在hero表中添加数据

mysql8.0 [db_test]>insert into hero (name,nickname,address,group_,email,telephone)
    -> values
    -> ('孙悟空','齐天大圣','花果山','西天取经','[email protected]',5464575672),
    -> ('唐玄奘','唐僧','长安','西天取经','[email protected]',5675672),
    -> ('曹孟德','曹操','许昌','魏国','[email protected]',89999912), 
    -> ('诸葛亮','孔明先生','襄樊','蜀国','[email protected]',12444444233);
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0
 

(5)查看hero表的结构

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)查看hero表数据

mysql8.0 [db_test]>select * from hero;
+----+-----------+--------------+-----------+--------------+-----------------+------------+
| id | name      | nickname     | address   | group_       | email           | telephone  |
+----+-----------+--------------+-----------+--------------+-----------------+------------+
|  1 | 孙悟空    | 齐天大圣     | 花果山    | 西天取经     | [email protected]   | 1234322342 |
|  2 | 唐玄奘    | 唐僧         | 长安      | 西天取经     | [email protected] |  213213212 |
|  3 | 曹孟德    | 曹操         | 许昌      | 魏国         | [email protected]'  | 2132131212 |
|  4 | 诸葛亮    | 孔明先生     | 襄樊      | 蜀国         | [email protected]  |  123123123 |
+----+-----------+--------------+-----------+--------------+-----------------+------------+
4 rows in set (0.00 sec)
 
mysql8.0 [db_test]>