2011-12-13 94 views
1

誰能幫我,我怎麼能解決這個錯誤排序規則的非法組合(utf8_general_ci,COERCIBLE)和(latin1_swedish_ci,隱含的)

Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation 'locate' 

我已執行我的存儲過程在Server1和它的做工精細,但它會在服務器2上引發錯誤。我已經檢查了兩臺服務器上的所有表和存儲過程,它們都是一樣的。

任何人都可以幫助我解決這個問題和解決方案。

這裏是存儲過程。

DELIMITER $$ 

DROP PROCEDURE IF EXISTS `UPDATEPASSWORD` $$ 
CREATE DEFINER=`root`@`localhost` PROCEDURE `UPDATEPASSWORD`(IN empn CHAR(9), IN oldpassword VARCHAR(255), IN newpassword VARCHAR(255)) 
main:BEGIN 
DECLARE diction INT; 
DECLARE prevpass INT; 
DECLARE len INT; 
DROP TABLE IF EXISTS passwordstatus; 
CREATE TEMPORARY TABLE passwordstatus 
(
    `passwordstatus` VARCHAR(127) 
); 

PREPARE stmt1 FROM "select count(seqid) into @diction 
        from dictionary where instr(?,word)>0 or instr(REVERSE(?),REVERSE(word))>0 "; 
SET @a = newpassword; 
SET @b = newpassword; 
EXECUTE stmt1 USING @a,@b; 
DEALLOCATE PREPARE stmt1; 
IF @diction > 0 THEN 
    START TRANSACTION; 
    PREPARE stmt1 FROM "INSERT INTO passwordstatus VALUES (?)"; 
    SET @a = "PASSWORD CONTAINS COMMONLY USED WORDS"; 
    EXECUTE stmt1 USING @a; 
    DEALLOCATE PREPARE stmt1; 
    COMMIT; 
    SELECT * FROM passwordstatus; 
    LEAVE main; 
END IF; 

PREPARE stmt1 FROM "select count(seqid) into @prevpass 
        from prevpass where (instr(sha1(?),passwd)>0 or instr(REVERSE(sha1(?)),REVERSE(passwd))>0)and empno = ?"; 
SET @a = newpassword; 
SET @b =empn; 
EXECUTE stmt1 USING @a, @a, @b; 
DEALLOCATE PREPARE stmt1; 
IF @prevpass > 0 THEN 
    START TRANSACTION; 
    PREPARE stmt1 FROM "INSERT INTO passwordstatus VALUES (?)"; 
    SET @a = "PASSWORD CONTAINS PREVIOUSLY USED PASSWORDS"; 
    EXECUTE stmt1 USING @a; 
    DEALLOCATE PREPARE stmt1; 
    COMMIT;  
    SELECT * FROM passwordstatus; 
    LEAVE main; 
END IF; 

PREPARE STMT1 FROM " SELECT COUNT(seqid) INTO @prevpass FROM prevpass where empno = ? "; 
SET @a = empn; 
EXECUTE STMT1 USING @a; 
DEALLOCATE PREPARE STMT1; 
START TRANSACTION; 
IF @prevpass = 6 THEN 
    PREPARE STMT1 FROM "DELETE FROM prevpass WHERE EMPNO = ? ORDER BY seqid LIMIT 1"; 
    SET @a = empn; 
    EXECUTE STMT1 USING @a; 
    DEALLOCATE PREPARE STMT1; 
END IF; 
PREPARE STMT FROM " UPDATE emppass SET passwd = sha1(?),lastupdate = now() WHERE empno = ? "; 
SET @a = newpassword; 
SET @b = empn; 
EXECUTE STMT USING @a,@b; 
DEALLOCATE PREPARE STMT; 
PREPARE STMT1 FROM " INSERT INTO prevpass (empno,passwd,createdate) VALUES (?,sha1(?),now())"; 
SET @a = empn; 
SET @b = newpassword; 
EXECUTE STMT1 USING @a,@b; 
DEALLOCATE PREPARE STMT1; 
PREPARE stmt1 FROM "INSERT INTO passwordstatus VALUES (?)"; 
    SET @a = "PASSWORD UPDATED SUCCESSFULLY"; 
    EXECUTE stmt1 USING @a; 
    DEALLOCATE PREPARE stmt1; 
COMMIT; 
SELECT * FROM passwordstatus; 

END $$ 

DELIMITER ; 
+1

沒有實際的SQL,很難想象 – ajreal

回答

3

嘗試在每個參數前都有一個BINARY命令。

SHA1(BINARY ?) 
BINARY passwd 
2

查詢您正在執行。兩臺服務器上表的

檢查表校對:

,我可以看到現在,你可以做到這一點

select table_name, table_collation 
    from information_schema.tables 
where table_schema = database(); 

並檢查列的排序規則:

select * 
from information_schema.columns 
where table_schema = database() 
    and collation_name is not null 
    and collation_name not like 'utf8%'; 

可能這可以幫助你。

相關問題