Mysql turns ' into ’?

后端 未结 3 712
我在风中等你
我在风中等你 2021-01-02 00:31

How can I stop mysql from converting \' into ’ when I do an insert?

i believe it has something to do with charset or something?

3条回答
  •  萌比男神i
    2021-01-02 01:09

    The single quotation mark you posted is called an 'acute accent', which is often converted from the generic single quotation mark by some web applications. It's a UTF8 character, which when inserted into a Latin-1 database translates to '’'. This means that you need to change MySQL's charset to UTF8, or alternatively change your website's charset to Latin-1. The former would be preferred:

    ALTER DATABASE YourDatabase CHARACTER SET utf8;
    ALTER TABLE YourTableOne CONVERT TO CHARACTER SET utf8;
    ALTER TABLE YourTableTwo CONVERT TO CHARACTER SET utf8;
    ...
    ALTER TABLE YourTableN CONVERT TO CHARACTER SET utf8;
    

提交回复
热议问题