헤르메스 LIFE

[mysql] 토비의 Spring3.0 예제 DB 구축 본문

Database

[mysql] 토비의 Spring3.0 예제 DB 구축

헤르메스의날개 2012. 4. 15. 01:56
728x90

mysql 을 다운 받습니다. ( http://www.mysql.com/downloads/mysql/ )


개인적인 귀차니즘 때문에 설치버젼이 아닌 압축버젼을 받았습니다.


적당한 곳에 압축을 풀고, %MYSQL_HOME%/bin 폴더에서 실행합니다.



> mysqld


> mysql -u root -p mysql


# create database db명;

mysql> create database springbook;


# grant all privileges on db명.* to 계정명@"localhost" identified by '비밀번호';

mysql> grant all privileges on springbook.* to spring@'localhost' identified by 'book';


mysql> \s [또는 status]

--------------

mysql  Ver 14.14 Distrib 5.5.23, for Win32 (x86)


Connection id:          7

Current database:       mysql

Current user:           root@localhost

SSL:                    Not in use

Using delimiter:        ;

Server version:         5.5.23-log MySQL Community Server (GPL)

Protocol version:       10

Connection:             localhost via TCP/IP

Server characterset:    latin1

Db     characterset:    latin1

Client characterset:    utf8

Conn.  characterset:    utf8

TCP port:               3306

Uptime:                 1 min 12 sec


Threads: 4  Questions: 16  Slow queries: 0  Opens: 34  Flush tables: 1  Open tables: 27  Queries per second avg: 0.222

--------------


# Character Set 변경하기

mysql> SET character_set_server = utf8;

mysql> SET character_set_client = utf8;

mysql> SET character_set_results = utf8;

mysql> SET character_set_connection = utf8;

mysql> SET character_set_database = utf8;

mysql> SET character_set_filesystem = utf8;

mysql> ALTER DATABASE springbook DEFAULT CHARACTER SET utf8;


# 확인

mysql> show variables like 'c%';


character_set_client : utf8

character_set_connection : utf8

character_set_database : utf8

character_set_results : utf8

character_set_server : utf8

character_set_system : utf8

character_sets_dir : /usr/share/mysql/charsets/

collation_connection : utf8_general_ci

collation_database : utf8_general_ci

collation_server : utf8_general_ci


mysql> create table users (

    -> id varchar(10) primary key,

    -> name varchar(20) not null,

    -> password varchar(10) not null

    -> );

Query OK, 0 rows affected (0.05 sec)


mysql> show tables; : 각 항목들을 나열

+----------------------+

| Tables_in_springbook |

+----------------------+

| users                |

+----------------------+

1 row in set (0.00 sec)

728x90