라벨이 mysql인 게시물 표시

mysql, mariadb 채번 방법 또는 auto increment field -> LAST_INSERT_ID의 thread(concurrent) safe 여부

채번할때, last_insert_id 로 select되는 값은 connection basis라는... ** 즉, 해당 connection에서 증가된 값으로 select 된다는... * 단, 같은 connection에서 여러번 insert를 해도 첫번째 insert시 증가한 auto_increment 값만 select한다는.... ** commit 시점이 중요한듯(?) from : https://dev.mysql.com/doc/refman/5.0/en//information-functions.html#function_last-insert-id The ID that was generated is maintained in the server on a per-connection basis. This means that the value returned by the function to a given client is the first AUTO_INCREMENT value generated for most recent statement affecting an AUTO_INCREMENT column by that client. This value cannot be affected by other clients, even if they generate AUTO_INCREMENT values of their own. This behavior ensures that each client can retrieve its own ID without concern for the activity of other clients, and without the need for locks or transactions. The value of LAST_INSERT_ID() is not changed if you set the AUTO_INCREMENT column of a row to a non-“magic” value (that is, a value that is not NULL and no...

Mysql Decimal 컬럼에 insert시 발생하는 Data truncation 오류 (Out of range value for column)

experience decimal(10, 2)에 특정 double형 data를 insert 시도시 아래와 같은 상황 발생.   com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'column_name' at row 65  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3564)  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)  at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)  at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)   값이 1억보다 큰 data를 넣으려 할때 발생하는 듯...   * 대충 찾아보니, decimal 앞 10은 전체 자리수이고, 뒤에 2는 소수점 하위 자리수라는... ** 즉, 소수점 자리수가 2개를 차지하기 때문에 0보다 큰 정수부분은 8개만 허용이 된다는... ** 1억보다 큰 경우, 8개보다 더큰 number를 필요로 하기 때문에 발생하는 것으로 보임.    ** 소수점 자리수도 3자리이상 자리수를 넣으려하면 같은 오류 발생가능한 듯...(?)   from : http://stackoverflow.com/questions/12057695/mysqldatatruncation-out-of-range-value-for-column

mysql Dump 실행시 발생하는 Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect 에러 해결방법

experience mysqldump를 실행하여, backup을 하려 했으나, 위와 같은 오류 발생.   * 원인 : 대충 확인해 보니, mysqldump를 실행하면 default socket 파일 경로(/tmp/mysql.sock)를 참조하는 듯..(아니면 이미 떠있는 mysql이 위 경로를 바라보도록 되어 있던지... @.@)     * dump실행시 아래 옵션을 추가해주면 정상동작하는 듯...   ** --socket=/실제경로/mysql.sock

MMM으로 묶인 MYSQL DB 장비가 Master인지 Slave인지 구분하는 방법(Master 장비 찾는 방법(?))

* 각 장비에 들어가서 아래 명령어 실행후, 값이 ON이면 slave, OFF면 master라는...   show variables like 'read_only'     * 단, 롤 체인지(role change) 과정에서 해당 값을 DBA(?) 또는 관리자가 수동으로 변경을 해줘야 하는데, 이를 빠뜨리면 ON으로 유지될 수 있다는....