# How to show the last queries executed on MySQL?

In MySQL, it is possible to show the last queries that were executed. You can
view them as a table or file.

## Output query history into a table

To output executed queries into a table, run the following MySQL commands:

```sql
SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
```

Then, take a look at `mysql.general_log` table, where you see the query history:

```sql
SELECT * FROM mysql.general_log
```

## Output query history into a file

To output query history into a file instead of a table, run the following MySQL
commands:

```sql
SET GLOBAL log_output = "FILE";
SET GLOBAL general_log_file = "/path/to/your/logfile.log";
SET GLOBAL general_log = 'ON';
```

Don’t forget to replace `"/path/to/your/logfile.log"` with the actual log file
you wish to use. Then you can just open the file to see query history. To see
the last 10 line, run the following command:

```bash
tail /path/to/your/logfile.log
```

[ad-logs]
