Collation only affects the sorting of text; it does not affect the actual set of stored data.
I would recommend this configuration:
Set the character set only for the entire database , so you do not need to install it for each table separately. The character set is inherited from the database to the tables in columns. Use utf8 as a character set.
Set the character set for connecting to the database . Run these queries after connecting to the database:
SET CHARACTER SET 'utf8' SET NAMES 'utf8'
Define the character set for the page using the HTTP header and / or HTML meta tag. One of them is enough. Use utf-8 as a charset .
That should be enough.
If you want to have Spanish rows sorted correctly, set the sort order for the entire database. utf8_spanish_ci should work ( ci means case insensitive). Without proper matching, accented Spanish characters will always be sorted last.
Note : it is possible that the character set that you already have in the table is broken because the incorrect character set configuration was previously installed. You must first check it with some DB client to rule out this case. If it is broken, just paste your data into the desired character set configuration.
objects have a character set attribute that can be set explicitly or inherited (server> database> table> column), so itโs best to set it for the entire database
the client connection also has a character set attribute, and it tells the database in which the encoding is "re sending data
If the character set of the client and the target is different, the data that you send to the database is automatically converted from the character set of the connection to the character set of the object.
So, if you have, for example, data in utf8 , but the client connection is set to latin1 , the database will break the data because it will try to convert utf8 like this, latin1 .
source share