> For the complete documentation index, see [llms.txt](https://koseungbin.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://koseungbin.gitbook.io/wiki/books/undefined-1/dbms/mysql-1.md).

# MySQL과 커넥션 만들기, 데이터베이스에 전화걸기

MySQL에 로그인했을 때 표시되는 메시지를 살펴보면 커넥션이 성립되었음을 알 수 있다.

```bash
Your MySQL connection id is 11
```

동시에 복수의 사용자와 연결하기 위해 각각의 커넥션에 번호를 부여한다.

커넥션의 시작과 종료 사이에 DBMS 와 다양한 교환을 하게 되는데, **교환의 시작과 종료까지의 단위**를 **'세션(Session)'** 라고 한다. 커넥션과 세션은 유사한 개념 같아 보이지만, 정확하게는 커넥션이 확립된 후에 세션이 만들어진다.

![](/files/-LbXtvXNnYeTcIBpD0Rj)

##

거의 모든 DBMS 에는 커넥션의 상태나 수를 조사하기 위한 명령어가 있다. MySQL 의 경우 'show status' 명령어로 확인할 수 있다.

```sql
mysql> show status like 'Threads_connected';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Threads_connected | 1     |
+-------------------+-------+
1 row in set (0.00 sec)
```

이처럼 복수의 사용자가 동시에 작업할 수 있다는 것이 데이터베이스를 이용하는 이점 중 하나이다.

## &#x20;

커넥션 종료 명령어는 'quit' 이다.

```sql
mysql> quit;
Bye
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://koseungbin.gitbook.io/wiki/books/undefined-1/dbms/mysql-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
