Differences between revisions 4 and 23 (spanning 19 versions)
Revision 4 as of 2005-11-30 19:00:54
Size: 2393
Editor: 143
Comment: 사용자 추가 방법 추가. 최신버젼을 5.0 으로 변경.
Revision 23 as of 2011-08-03 11:00:39
Size: 5421
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from MySql
Line 3: Line 4:
http://www.mysql.com
http://sourceforge.net/projects/mysql/
 * http://www.mysql.com
 * http://sourceforge.net/projects/mysql/
Line 8: Line 9:
ApmModPythonInstallInLinux페이지에 가면, 기본적인 설치방법들이 소개되어 있다. [Python]으로 연동하여 쓸려면, MySqlDb모듈을 추가로 설치해야 한다. ApmModPythonInstallInLinux페이지에 가면, 기본적인 설치방법들이 소개되어 있다. [Python]으로 연동하여 쓸려면, [MySQLdb]모듈을 추가로 설치해야 한다. 일반적으로 3306 포트를 사용한다.
Line 10: Line 11:
----
mysql 5.0 version 이 나와있다. 중첩쿼리문을 4.1 version 부터 사용할 수 있게 되었으며, Views,Cursors 같은 새로운 기능이 들어갔고, BIT 라는 새로운 Numerical type 이 생겼다.
<<TableOfContents>>

== 관련기사 및 정보 ==

관련포스트
 * http://www.scribd.com/doc/2565263/The-top-20-design-tips-for-MySQL-Enterprise-data-architects

{{|
오픈소스를 장려하는 정부정책에 대한 기대가 있으며 초기에는 공공 프로젝트에 도입이 예상된다”며 “특히 공공기관은 DBMS 도입에 있어 컨설팅이나 서비스가 필요하기 때문에 책임소재가 명확해야 하는데 LDS라는 책임자가 생겼기 때문에 가능성이 있다”고 설명했다. -- [[http://www.zdnet.co.kr/news/enterprise/dbms/0,39031095,39161483,00.htm|MySQL의 습격「MS, 오라클 게 섯거라!」]]
|}}

== New functions ==
mysql 5.0 version 이 나와있다. 변경 사항
 * Views, StoredProcedures, Cursors 기능 추가
 * BIT type 추가
 * VARCHAR 형이 65,632 byte 까지 지원하도록 변경.
Line 32: Line 47:
mysql> GRANT ALL PRIVILEGES on chap11.* to 'ID'@'localhost' identified by 'PASSWORD'; mysql> GRANT ALL PRIVILEGES on dbname.* to 'ID'@localhost identified by 'PASSWORD';
Line 36: Line 51:
mysql> GRANT ALL PRIVILEGES on chap11.* to 'ID'@'%' identified by 'PASSWORD'; mysql> GRANT ALL PRIVILEGES on dbname.* to 'ID'@'%' identified by 'PASSWORD';
Line 51: Line 66:
== 각종 정보 ==
가끔 테이블이 깨지는 경우가 발생할 수 있다. 약 1년에 한두번 발생한다고... [http://www.linux.co.kr/tips/content.html?msg_id=1341 참고]
== 사용 ==
=== 테이블 깨짐 =
==
가끔 테이블이 깨지는 경우가 발생할 수 있다. 약 1년에 한두번 발생한다고... [[http://www.linux.co.kr/tips/content.html?msg_id=1341|참고]]
Line 62: Line 78:
{{{
[root@localhost]# mysql -u root -p
Enter password: MySQL_ROOT_PASSWORD
mysql> use DB_NAME;
Database changed
mysql> lock tables TABLE_NAME read;
mysql> lock tables TABLE_NAME write;
mysql> flush tables;
mysql> exit
[root@localhost]# cd /var/lib/mysql/DB_NAME
[root@locahost]# myisamchk -ro TABLE_NAME
[root@localhost]# mysql -u root -p
Enter password: MySQL_ROOT_PASSWORD
mysql> use DB_NAME;
Database changed
mysql> unlock tables;
mysql> flush tables;
}}}

=== 설정 변수 보기 ===
{{{
mysql> show variables like "c%"; # c로 시작하는 환경 변수 보기
}}}

=== 한글문제 ===
4.1버전이후로, encoding의 설정이 약간 바뀌였다. [UTF8]을 기본으로 쓰고자 한다면, /etc/mysql/my.conf 에
{{{
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
[mysqldump]
default-character-set=utf8
}}}

DB 생성시에는 다음 명령으로
{{{
CREATE DATABASE 데이타베이스_이름 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
}}}

만일 다른 인코딩으로 이미 저장되어 있는 경우는 (특히 [PHP]의 경우, ) 연결후, 아래명령을 삽입한다.
{{{
@mysql_query('set names utf8', $connect_db);
}}}

euc-kr 용 db를 만들고 싶다면,
{{{
create database dbname default character set euckr;
}}}

For Python,
{{{#!python
db = MySQLdb.connect(
    host='...',
    user='...',
    passwd='...',
    read_default_file='/etc/mysql/my.cnf',
    read_default_group='mysql')
}}}

그외,
 1. [[http://kldp.org/node/81341|MySQL 5.0 으로 업그레이드 할 때 UTF-8, EUC-KR 같이 쓰는 경우 캐릭터셋 문제 해결방법, v1.3]]

=== 암호 분실시 ===

UbuntuLinux에서
{{{
# /etc/init.d/mysqld stop
# mysqld_safe --skip-grant-tables
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.8-standard

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

mysql> UPDATE mysql.user SET Password=PASSWORD('xxxx') where User='root';
Query OK, 5 rows affected (0.09 sec)
Rows matched: 5 Changed: 5 Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> Bye
# /etc/init.d/mysql restart
}}}

MySQL. Most popular OpenSource RelationalDatabase Management system

예전에 NASA에서 그네들의 DB시스템을 [Oracle]에서 MySql로 바꾸었단 얘기가 있다. 10만레코드(맞나?)이하의 데이터에서 가장 빠른 속도를 낸다고 함

ApmModPythonInstallInLinux페이지에 가면, 기본적인 설치방법들이 소개되어 있다. [Python]으로 연동하여 쓸려면, [MySQLdb]모듈을 추가로 설치해야 한다. 일반적으로 3306 포트를 사용한다.

관련기사 및 정보

관련포스트

{{| 오픈소스를 장려하는 정부정책에 대한 기대가 있으며 초기에는 공공 프로젝트에 도입이 예상된다”며 “특히 공공기관은 DBMS 도입에 있어 컨설팅이나 서비스가 필요하기 때문에 책임소재가 명확해야 하는데 LDS라는 책임자가 생겼기 때문에 가능성이 있다”고 설명했다. -- MySQL의 습격「MS, 오라클 게 섯거라!」 |}}

New functions

mysql 5.0 version 이 나와있다. 변경 사항

  • Views, StoredProcedures, Cursors 기능 추가

  • BIT type 추가
  • VARCHAR 형이 65,632 byte 까지 지원하도록 변경.

기본 설치

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root  .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &

사용자 추가 방법

명령어를 이용해서 추가 하기

localhost 에서 사용할 수 있는 사용자 추가

mysql> GRANT ALL PRIVILEGES on dbname.* to 'ID'@localhost identified by 'PASSWORD';

외부에서 사용할 수 있는 사용자 추가

mysql> GRANT ALL PRIVILEGES on dbname.* to 'ID'@'%' identified by 'PASSWORD';

Table에 직접 넣기

  • 1. root 권한으로 mysql을 실행한다.
  • 2. use mysql;
  • 3. update user set host='%' where user = 'destine'; ( 원래 host는 localhost로 되어 있을텐데 어느 곳에서나 접속 할 수 있게 %로 바꿔준다. )
  • 4. update db set host='%' where user = 'destine'; ( 위와 마찬가지 )
  • 5. flush privileges;

기본 명령어들

  • show databases
  • show tables
  • show index from [table name]
  • describe tablename

사용 팁

테이블 깨짐

가끔 테이블이 깨지는 경우가 발생할 수 있다. 약 1년에 한두번 발생한다고... 참고

Can't open file: 'xxxxxx.MYD'.(errno: 145)

# cd /var/lib/mysql/mysql
# myisamchk -r xxxxxx.*   # -r : recovery, -o : safe recovery, -f : force 

[root@localhost]# mysql -u root -p
Enter password: MySQL_ROOT_PASSWORD
mysql> use DB_NAME;
Database changed
mysql> lock tables TABLE_NAME read;
mysql> lock tables TABLE_NAME write;
mysql> flush tables;
mysql> exit
[root@localhost]# cd /var/lib/mysql/DB_NAME
[root@locahost]# myisamchk -ro TABLE_NAME
[root@localhost]# mysql -u root -p
Enter password: MySQL_ROOT_PASSWORD
mysql> use DB_NAME;
Database changed
mysql> unlock tables;
mysql> flush tables;

설정 변수 보기

mysql> show variables like "c%";  # c로 시작하는 환경 변수 보기

한글문제

4.1버전이후로, encoding의 설정이 약간 바뀌였다. [UTF8]을 기본으로 쓰고자 한다면, /etc/mysql/my.conf 에

[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
[mysqldump]
default-character-set=utf8

DB 생성시에는 다음 명령으로

CREATE DATABASE 데이타베이스_이름 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

만일 다른 인코딩으로 이미 저장되어 있는 경우는 (특히 [PHP]의 경우, ) 연결후, 아래명령을 삽입한다.

@mysql_query('set names utf8', $connect_db);

euc-kr 용 db를 만들고 싶다면,

create database dbname default character set euckr;

For Python,

   1 db = MySQLdb.connect(
   2     host='...',
   3     user='...',
   4     passwd='...',
   5     read_default_file='/etc/mysql/my.cnf',
   6     read_default_group='mysql')

그외,

  1. MySQL 5.0 으로 업그레이드 할 때 UTF-8, EUC-KR 같이 쓰는 경우 캐릭터셋 문제 해결방법, v1.3

암호 분실시

UbuntuLinux에서

# /etc/init.d/mysqld stop
# mysqld_safe --skip-grant-tables
# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.8-standard

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

mysql> UPDATE mysql.user SET Password=PASSWORD('xxxx') where User='root';
Query OK, 5 rows affected (0.09 sec)
Rows matched: 5  Changed: 5  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> Bye
# /etc/init.d/mysql restart


CategoryProgram

MySQL (last edited 2012-06-20 17:02:03 by 61)

web biohackers.net