상세 컨텐츠

본문 제목

mysql 서버 접속

Database/My-sql

by 마니씨 2009. 11. 19. 16:05

본문


[ace20@it ~]$ mysql -u mmy20 -p     -> 유저 mmy20 으로 비밀번호를 사용하여 mysql 에 접속하겠다.
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 894 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;     -> 접속한곳의 db 를 확인하자.
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ace20_db           |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> select now();     -> 현재 시간을 확인.
+---------------------+
| now()               |
+---------------------+
| 2009-11-16 15:34:50 |
+---------------------+
1 row in set (0.00 sec)

mysql> select user();     -> 사용자 확인
+-----------------+
| user()          |
+-----------------+
| mmy20@localhost |
+-----------------+
1 row in set (0.00 sec)

mysql> show tables;     -> table 확인
ERROR 1046 (3D000): No database selected
mysql> Aborted

mysql> use ace20_db     ->ace20_db로 접속하겠다.
Database changed
mysql> show tables;
Empty set (0.00 sec)

-> 테이블을 생성해 보자
mysql> create table people(
    -> name char(20),
    -> age int);
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;     -> 테이블 목록 확인
+--------------------+
| Tables_in_ace20_db |
+--------------------+
| people             |
+--------------------+
1 row in set (0.00 sec)

mysql> desc people;     -> 테이블의 스키마 확인
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name  | char(20) | YES  |     | NULL    |       |
| age   | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> create table test1116_1(
    -> name varchar(20)
    -> , korean int
    -> , english int
    -> , math int
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> desc test1116_1;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name    | varchar(20) | YES  |     | NULL    |       |
| korean  | int(11)     | YES  |     | NULL    |       |
| english | int(11)     | YES  |     | NULL    |       |
| math    | int(11)     | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> show tables;
+--------------------+
| Tables_in_ace20_db |
+--------------------+
| people             |
| test1116_1         |
+--------------------+
2 rows in set (0.00 sec)

'Database > My-sql' 카테고리의 다른 글

table column 의 변경 - alter  (0) 2010.01.12
create table  (0) 2010.01.12
db backup 복구하기  (0) 2010.01.11
사용자 계정, 비밀번호 변경.  (0) 2009.12.07

관련글 더보기