[toc]

前面说了MySQL Linux平台和Windows平台的安装

下面开始是MySQL的一些学习笔记

前面我们说了如果构造数据

这节开始说MySQL 的备份

环境为MySQL 5.7.25 




在解释命令之前我们先弄清楚数据库中有哪些对象

在第一节的笔记中我们建了数据库,函数,存储过程和两张表

这节我们再建几个其他的对象如触发器 event等


## 1. 查询数据库

```
mysql>show databases;
```


[image:489 size:orig]




## 2. 查询表

```
mysql>use test
mysql>show tables;
```

[image:490 size:orig]


## 3.  查看存储过程和函数

```
select `name` from mysql.proc where db = 'test' and `type` = 'PROCEDURE' ;  //存储过程
select `name` from mysql.proc where db = 'test' and `type` = 'FUNCTION'  ; //函数
```

[image:491 size:orig]

[image:492 size:orig]

## 4. 查看触发器

我们先建立一个触发器


首先建time表

```
use test    
create table time (time varchar(100))
```

之后建trigger



```
use test

CREATE TRIGGER trig1 AFTER INSERT
    ON  isam_table FOR EACH ROW
    INSERT INTO time VALUES(NOW());
```


然后我们查询trigger

```
SHOW TRIGGERS from test \G
```

[image:493 size:orig]

注意:time表必须事先建立

## 5. 查看event


这里我们新建一个event

首先在test数据库中建立测试表


```
mysql> use test
mysql> drop table if exists events_list;
mysql> create table events_list(event_name varchar(20) not null, event_started timestamp not null);
```

之后建立event

```
create event test.event_minute 
on schedule 
every  1 minute  
do insert into events_list values('event_now', now());
```


开启event 

```
 set global event_scheduler =1;
```

最后查看进程是否启动

```
 show processlist;
```

[image:494 size:orig]


等待几分钟后看结果

[image:495 size:orig]

我们使用如下语句查询数据库中的events

```
show events\G
```

[image:496 size:orig]


好了今天就到这了,下次讲mysqldump的命令