I'm trying to import data into my table. The source is CSV in UTF8 encoding into my MySQL UTF8MB4 table.
Originally i thought the encoding was wrong for the language which is Russian (for this failed row) but it turns out its a slash "/" in the string (or any other similar chars) and when i remove it then insert works to that point.
This data is multi language and has emoji too, what is the best way to handle the slash in the double quote enclosed string?
For example the slash in this is the problem "й\с"
When i run
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%'
I get
Variable_name
Value
character_set_client
utf8mb4
character_set_connection
utf8mb4
character_set_database
utf8mb4
character_set_filesystem
binary
character_set_results
utf8mb4
character_set_server
latin1
character_set_system
utf8
collation_connection
utf8mb4_general_ci
collation_database
utf8mb4_unicode_ci
collation_server
latin1_swedish_ci
Related
I need to find file where I can change these variables into utf-8. I can't find them in my.cnf files.
collation_connection latin1_swedish_ci
collation_database latin1_swedish_ci
collation_server latin1_swedish_ci
character_set_client latin1
character_set_connection latin1
character_set_database latin1
character_set_results latin1
character_set_server latin1
From mysql doc You can change character_set configuration
[client]
character-sets-dir=/usr/local/mysql/share/mysql/charsets
[client]
character-sets-dir="C:/Program Files/MySQL/MySQL Server 5.6/share/charsets"
http://dev.mysql.com/doc/refman/5.6/en/charset-configuration.html
I have an installation of MySQL 5.7 on a Windows 7 machine.
I need to change the character set of the database in order to persist emoji.
The configuration into my.ini:
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
default-character-set = utf8mb4
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
Into the windows services I saw that the configuration file path that is loaded is correct.
Looking into database properties with the query:
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
I got the following results:
Variable_name Value
character_set_client utf8
character_set_connection utf8
character_set_database utf8mb4
character_set_filesystem binary
character_set_results utf8
character_set_server utf8
character_set_system utf8
collation_connection utf8_general_ci
collation_database utf8mb4_general_ci
collation_server utf8_general_ci
So, the values of collation_server, character_set_system, character_set_server, character_set_results, character_set_connection, character_set_client are wrong.
How can I fix them?
Thanks.
After connecting to MySQL, perform SET NAMES utf8mb4. That will establish that your client is using the full 4-byte encoding for reading/writing.
You can do this in my.cnf/my.ini:
init_connect = 'SET NAMES utf8mb4'
but keep in mind that when connecting as root (or any SUPER user), init_connect is ignored.
Also, the tables/columns must be CHARACTER SET utf8mb4.
i have a problem...
we moved site from server to server...
and after that our site ascii code not working true...
if i add an ascii code to editor on vbulletin there is problem after saving post...
i saw on database..
▄ ; must be save but saving „â–
there is a problem but how can i solve this problem..
i looked show variables ...
character_set_client utf8
character_set_connection latin1
character_set_database latin1
character_set_filesystem binary
character_set_results utf8
character_set_server latin1
character_set_system utf8
character_sets_dir /usr/share/mysql/charsets/
collation_connection latin1_swedish_ci
collation_database latin1_swedish_ci
collation_server latin1_swedish_ci
but i looked on vbulletin sql query
all of them latin1...only character_set_system utf8 but i cant latin1 all of them..
how can i fix it...
please help me ...
i looked 3 months ...
sorry my bad english.
I'm currently attempting to switch from my shared inmotionhosting account (have received AWEFUL service lately) to an Amazon EC2 server that I've set up. I'm having trouble with getting the encryption function working in the EC2 account.
In my PHP code, all text gets encrypted by mcrypt before being put into the SQL. I have deduced that those mcrypt characters are responsible for all my queries throwing errors. (I know it's because of encoding issues, but Google searches on the subject aren't very clear on where I need to focus my attention.)
A more simplified way of explaining the problem. On my new hosting account this SQL query doesn't work:
UPDATE mydatabase.clients SET firstname='\'å».”é¶Q' WHERE id_client=65
But this does
UPDATE mydatabase.clients SET firstname='Test' WHERE id_client=65
So that tells me the mcrypt function is using characters that the SQL database doesn't understand and thus the queries aren't working.
Some other info for you...
When I run "SHOW VARIABLES LIKE 'character_set_%'" on the working database I get this:
Variable_name Value
character_set_client utf8
character_set_connection utf8
character_set_database latin1
character_set_filesystem binary
character_set_results utf8
character_set_server latin1
character_set_system utf8
When I do that on the nonworking database I get:
Variable_name Value
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server utf8
character_set_system utf8
I saw the difference in character_set_database and ran this line of code:
ALTER DATABASE mydatabase DEFAULT CHARACTER SET latin1
It successfully changed the character_set_database to "latin1" to match the other, but didn't solve the problem.
Finally, all my columns in my tables are using the Collation "latin1_swedish_ci"
Any help you could give would be very very appreciated!
Store your encrypted strings as binary (or a similar) type. Also make sure you are escaping the encrypted string. Both are important parts to doing this right!
I've been working with MySQL and Mcrypt and I store my encrypted data and initialization vectors as binary and I escape all of these strings before they get put in a query. Works like a charm.
I'm a little worried about the absence of this variable when I execute the show variables command. This is what I get when I execute show variables like 'char%':
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_results utf8
character_set_server utf8
character_set_system utf8
character_sets_dir /usr/share/mysql/charsets/
I wonder why this is happening. What does it mean? can I just add it to the my.cnf file?
Thank you...
Edit: Sorry, I recently noted that I didn't specify which variable we're talking about (though I said it in the title). The variable is character_set_filesystem. Thanks.
http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_character-set-filesystem
Version Introduced 5.1.6
So most likely you have mysql < 5.1.6