mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 5.7.41 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
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 state
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
mysql> CREATE DATABASE UserLog;
Query OK, 1 row affected (0.02 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| UserLog | // 새로 생성된 데이터베이스
| mysql |
| performance_schema |
| sys |
+--------------------+
다음 명령어를 사용하여 DB를 선택한 후 table을 확인할 수 있다.
DB 선택
mysql> use UserLog;
Database changed
mysql> SHOW tables;
Empty set (0.00 sec) // 테이블을 방금 만들어서 당연히 비어있다.
mysql> CREATE table user_log(
-> ID INT NOT NULL AUTO_INCREMENT,
-> nickname VARCHAR(64),
-> money DEC(10, 2),
-> last_visit DATETIME,
-> PRIMARY KEY(ID)
-> );
Query OK, 0 rows affected (0.07 sec)
mysql> SHOW tables;
+-------------------+
| Tables_in_UserLog |
+-------------------+
| user_log |
+-------------------+
1 row in set (0.00 sec)
mysql> desc user_log;
+------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| nickname | varchar(64) | YES | | NULL | |
| money | decimal(10,2) | YES | | NULL | |
| last_visit | datetime | YES | | NULL | |
+------------+---------------+------+-----+---------+----------------+
4 rows in set (0.05 sec)