문제

I have an existing sql file which I want to import into a MySQL database 5.5 After import I do an: SELECT * FROM address; and instead of 'Straße' I get 'Straße' The import command is: mysql -uroot store < C:\PathTo\store.sql Using phpMyAdmin I get the same result. The interesting part is that this worked one year ago (Maybe with another MySQL DB version)

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);
...
도움이 되었습니까?

해결책

I solved my problem by adding ALTER DATABASE store DEFAULT CHARACTER SET latin1 COLLATE latin1_german1_ci; to the sql script file. So it looks like:

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;
...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top