Mysql2::Error: Incorrect string value

后端 未结 7 1462
青春惊慌失措
青春惊慌失措 2021-01-29 23:30

I have a rails application running on production mode, but all of the sudden this error came up today when a user tried to save a record.



        
相关标签:
7条回答
  • 2021-01-30 00:17

    the problem is caused by charset of your mysql server side. You can config manually like:

    ALTER TABLE your_database_name.your_table CONVERT TO CHARACTER SET utf8
    

    or drop the table and recreate it like:

    rake db:drop
    rake db:create
    rake db:migrate
    

    references:

    https://stackoverflow.com/a/18498210/2034097

    https://stackoverflow.com/a/16934647/2034097

    UPDATE

    the first command only affect specified table, if you want to change all the tables in a database, you can do like

    ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_general_ci;
    

    reference:

    https://stackoverflow.com/a/6115705/2034097

    0 讨论(0)
提交回复
热议问题