将sql导入为latin-1

时间:2013-05-01 13:45:33

标签: mysql import phpmyadmin latin1

我有一个现有的sql文件,我想导入MySQL数据库5.5导入后我做了一个:SELECT * FROM address; 而不是'Straße'我得到'Straße'导入命令是:mysql -uroot store< C:\ PathTo \ store.sql使用phpMyAdmin我得到相同的结果。有趣的是,这项工作在一年前开始了(也许还有另一个MySQL数据库版本)

DROP SCHEMA IF EXISTS store;
CREATE SCHEMA IF NOT EXISTS store DEFAULT CHARACTER SET=latin1;
USE store;

SET sql_mode = 'STRICT_ALL_TABLES';
SET NAMES latin1;
...
DROP TABLE IF EXISTS address;
CREATE  TABLE IF NOT EXISTS address (
  pk_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  zipCode DECIMAL(6,0)  NOT NULL,
  city VARCHAR(32) NOT NULL,
  street VARCHAR(32) NOT NULL,
  number VARCHAR(8) NOT NULL,
  fk_customer INT UNSIGNED NOT NULL,
  PRIMARY KEY (pk_id),
  CONSTRAINT
    FOREIGN KEY (fk_customer) 
    REFERENCES customer(pk_id)
    ON DELETE CASCADE 
    ON UPDATE CASCADE
);
...
insert into address (zipCode, city, street, number, fk_customer) values(111, "MyCity", "Straße", "7", 1);
...

1 个答案:

答案 0 :(得分:0)

我通过将ALTER DATABASE store DEFAULT CHARACTER SET latin1 COLLATE latin1_german1_ci;添加到sql脚本文件来解决了我的问题。所以它看起来像:

DROP SCHEMA IF EXISTS store;
CREATE SCHEMA IF NOT EXISTS store DEFAULT CHARACTER SET=latin1;
USE store;

ALTER DATABASE `store` DEFAULT CHARACTER SET latin1 COLLATE latin1_german1_ci;

SET sql_mode = 'STRICT_ALL_TABLES';
SET NAMES latin1;
...