The official start to solve the container can not be inserted redmine Chinese characters problem

  Before adopting docker-compose successfully built redmine, but found it impossible to insert Chinese characters in use, always reported internal server error error, look after the log, display the Insert abnormal, and now finally understand why many people do not apply the official installation of the mirror, the problem there has been, he will have to solve it, further analysis is due to the database character set is latin1, finally understand the problem, and then went to the official script, the default is utf8 encoding used, all database tables created are not specified character set, so a script to change the database, in order to put all of the data table is changed to the character set utf-8, manually is not desirable, the possibility of misuse database, so the use of stored procedures to implement, is given below stored procedure scripts.

DELIMITER $$
 
CREATE PROCEDURE `redmine`.`update_char_set`()
 
    BEGIN
     DECLARE done INT DEFAULT 0;
     DECLARE t_sql VARCHAR(256);
     DECLARE tableName VARCHAR(128);
     DECLARE lists CURSOR FOR SELECT table_name FROM `information_schema`.`TABLES` WHERE table_schema = 'redmine';
     DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
     OPEN lists;
     FETCH lists INTO tableName;
     REPEAT
        SET @t_sql = CONCAT('ALTER TABLE ', tableName, ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
        PREPARE stmt FROM @t_sql;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
     FETCH lists INTO tableName;
     UNTIL done END REPEAT;
     CLOSE lists;
    END$$
 
DELIMITER ;

The stored procedure is executed again on the server hosting the database,

Then change the character set and character set of the database, and then update each data table, execute the following script:

ALTER DATABASE redmine DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CALL redmine.update_char_set();

 

Guess you like

Origin www.cnblogs.com/jiangzhaowei/p/11300044.html