변군이글루

[mysql] 리눅스 쉘상태에서 DB 및 테이블 생성 본문

및___APM

[mysql] 리눅스 쉘상태에서 DB 및 테이블 생성

변군 변군이글루 2013.08.14 11:28

DB 생성
[root@byungun ~]# cat temp.sql
create database tempdb;

 

[root@byungun ~]# mysql -u root -p mysql < ./temp.sql

 

[root@byungun ~]# mysqlshow -u root -p
Enter password:
+--------------------+
| Databases |
+--------------------+
| information_schema |
| first |
| mysql |
| tempdb |
| test |
+--------------------+
[root@byungun ~]#

 

테이블 생성
[root@byungun ~]# cat temp_table.sql
create table temptable (
uid mediumint(3) NOT NULL,
name varchar(12) NOT NULL,
PRIMARY KEY (uid) );

 

[root@byungun ~]# mysql -u root -p tempdb < ./temp_table.sql
Enter password:
[root@byungun ~]#

 

[root@byungun ~]# mysqlshow -u root -p tempdb temptable
Enter password:
Database: tempdb Table: temptable
+-------+--------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+-------+--------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
| uid | mediumint(3) | | NO | PRI | | | select,insert,update,references | |
| name | varchar(12) | latin1_swedish_ci | NO | | | | select,insert,update,references | |
+-------+--------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
[root@byungun ~]#

 

 

 

 

2 Comments
  • 프로필사진 변군 변군이글루 2013.08.14 11:29 신고 [참고]
    mysqlshow [옵션] DB명 Table명
    mysqlshow -u root -p tempdb temptable
  • 프로필사진 변군 변군이글루 2013.08.14 11:29 신고 SQL문으로 확인
    [root@byungun ~]# mysql -u root -p tempdb
    Enter password:
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 26
    Server version: 5.0.77 Source distribution

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

    mysql> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | first |
    | mysql |
    | tempdb |
    | test |
    +--------------------+
    5 rows in set (0.00 sec)

    mysql> use tempdb
    Database changed

    mysql> show tables;
    +------------------+
    | Tables_in_tempdb |
    +------------------+
    | temptable |
    +------------------+
    1 row in set (0.00 sec)

    mysql> desc temptable;
    +-------+--------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +-------+--------------+------+-----+---------+-------+
    | uid | mediumint(3) | NO | PRI | NULL | |
    | name | varchar(12) | NO | | NULL | |
    +-------+--------------+------+-----+---------+-------+
    2 rows in set (0.00 sec)
댓글쓰기 폼