본문 바로가기
728x90
반응형
SMALL

MySQL16

mysql subquery limit 사용하기 일반적으로 mysql 에서 subquery 에 limit 을 두면 오류가 발생한다.ex) select count(*) from (select passwd from test where id = 'aaa' limit 3)tmp 이럴 경우 limit 절을 감싸고 alias 를 사용하게 되면 subquery 에서도 limit 을 사용할 수 있다.ex) select count(*) from( select * from ( select passwd from test where id = 'aaa' limit 3)as t)tmp 2013. 12. 24.
mysql dump import/export 1. DB명으로 덤프 받기 # /usr/local/mysql/bin/mysqldump –u 계정 –p db명 > 덤프파일명.sql 2. 특정 테이블만 덤프 받기# /usr/local/mysql/bin/mysqldump -u root -p db명 table명 > db명.table명.sql 3. 스키마 정보만 덤프 받기 // DB명 안에 모든 schema# /usr/local/mysql/mysqldump -u root -p -d db명 > db명_schema.sql// DB명 안에 모든 특정 table schema# /usr/local/mysql/mysqldump -u root -p -d db명 table명 > db명_table명_schema.sql 4. 덤프 파일로 복원# /usr/local/mysql/b.. 2013. 12. 24.
MySql 계층적 조회 쿼리 MySQL 에는 안타깝게도 Oracle 의 start with, connect by 를 지원하는 함수가 없다... 때문에 아래와 같이 function 을 만들어서 사용한다. 예제 테이블) test.servers_group create table test.servers_group ( group_idx int auto_increment, // P.K group_name varchar(40), // group name group_depth int, // level group_order int, // group 순서 parent_idx int, // parent group_idx manager_idx, // 관리자 idx (test.managers_info.idx) primary key(group_idx) )-.. 2013. 12. 24.
MySQL 외부 접속 (ERROR 1130 (00000): Host 'x.x.x.x' is not allowed to connect to this MySQL server) MySQL 접속 시 로컬에서는 잘되다가 외부에서 접속 시 다음과 같은 에러에 직면할 수 있다.C:\>mysql -u username -p password -h xxx.xxx.xxx.xxx ERROR 1130 (00000): Host 'x.x.x.x' is not allowed to connect to this MySQL server 이는 권한 문제로 root로 접속 후 다음 명령으로 해결할 수 있다.ex)계정 ID : test계정 PWD : testDataBase : beef_mng접속 가능 IP : 192.168.0.105GRANT ALL PRIVILEGES ON beef_mng.* TO test@"192.168.0.105" identified by 'test'; 모든 IP에 접속 가능하도록 하려면GR.. 2013. 12. 24.
728x90
반응형
LIST