I have strange problem, meaning:
in my company we have 2 kinds of databases 1 oracle and 1 mysql and 1 remote in hosting.
when ERP which is on oracle codding is set to utf-8 is making update or insert to remote mysql db everything is ok all chars like ńłóść are coded correctly, but doing the same update to my local mysql db chars like ńłóść are replaced by ?. I tried to
change coding from utf8_general_ci to utf8_unicode_ci didn't work,
change engine from InnoDB to MylSam didn't work
varsion of my local MySQL is 5.6.12
version of my remote MYSQL is 5
but i don't think there is problem, i use wamp 2.4
Can i check in what encoding query is ?
Short answer: use utf8mb4. Search for it on Stack Overflow, or see How to support full Unicode in MySQL databases.
Related
I am trying to save some Indian language content (read Hindi) from a website into a column in MySQL database. I am using SpringBoot and JPA to scrape the website and write the content.
Everything works fine on my local system (OSX). The same code is deployed on Ubuntu 16.04 LTS. It works fine except that the content of the relevant db column shows '????'. I presumed that it might be a problem with the COLLATION and CHARACTER SET of MySQL of the prod instance.
Indeed MYSQL version on my local machine was 8.x. The COLLATION on local db was utf8mb4_0900_ai_ci. The version on prod was 5.6, the COLLATION being utf8_x_x. Apparently, utf8mb4_0900_ai_ci, is not available for versions prior to 8.x.
I tried changing the COLLATION of columns (the entire schema for that matter) on local machine to utf8mb4_general_ci, as well as utf8mb4_unicode_ci. Both works fine on local DB. But the same collation, namely utf8mb4_general_ci & utf8mb4_unicode_ci still gives '?????' in the prod environment!
Could this be a problem other than 'COLLATION'? I am able to print the Hindi content on terminal, both on local and Ubuntu deployment. The problem is less likely with the client, as the same client (Datagrip) shows local schema content nicely and ubuntu DB content as cryptic question marks.
Have googled for two days. Any help would be appreciated.
I have ejabberd 16.01 that works well with MySQL, the problem is that it store only the regular emoji not the 4-bytes emoji. If I use a terminal, connect to the database, set the charset to utf8mb4 and run insert query, I can insert all type of icons, so the db is configured in the right way!
So i ejabberd put a message in offline storage all icons of 4-Bytes become "?????????" is there a way to set the charset to utf8mb4 for ejabberd mod offline?
How can I fix it? Do you have any ideas?
Thanks!
You need two things:
Ensure you have ejabberd 16.02 or newer that forces UTF8MB4 as default for emoji retrieval (Insertion is already in UTF8MB4 since years, if the table is correctly defined)
Ensure your MySQL schema has been properly created with UTFMB4 support.
I'm using MySQL Workbench and successfully migrating a SQL Server database used with SilverStripe PHP CMS to MySQL on Linux. Problem is when the content is displayed on the Linux web server I have to change encoding to Western (Windows-1252) to get the content to display correctly. The site on Windows IIS with SQL Server displays correctly with the default UTF-8 encoding.
In the manual migration editing section on MySQL Workbench some columns say Collation Latin1_General_CI_AS migrated to utf8_general_ci so I gather this is correct.
The site is setting <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> in the HTML.
Migration process:
Use MySQL Workbeanch to migrate from SQL Server to MySQL on
production server
Export MySQL database on production server to *.sql file
Import *.sql file into Linux server using PHPMyAdmin and default UTF-8 encoding
I'm not sure where in the migration process I need to fix this?
This might not be about the migration process at all.
If you are using PHP to access the new database, the connection charset might be incorrect.
After setting up the connection you should set the connection charset to UTF-8.
$db = new MySQLi(HOST, USER, PASSWORD, DATABASE);
$db->set_charset('utf8');
Or, if you are not using MySQLi:
mysql_connect(/*...*/);
mysql_set_charset('utf8');
There are 3 possibilities of what could have gone wrong:
Encoding miss-configuration at the original SQL-server setup. Look at this post for more details on how this can happen: https://stackoverflow.com/a/20824533/684229. In this case, the encoding in the SQL-database is incorrect, but due to wrong setup it displays correctly.
You made a mistake in the migration process. Then the encoding in the new MySQL database is incorrect.
The encoding in the new MySQL database is correct, but there is an encoding miss-configuration at the new Linux MySQL setup, which makes it look incorrect.
To check which case applies, you have to check the encoding in both databases by some independent tool which for sure (200% at least!!!) has the encoding configured correctly. I would use PHPMyAdmin in case of Linux, I don't know what's available on SQL server. But make sure that this tool is configured correctly, otherwise you will get fooled!!!
Post the result and I will expand my answer accordingly.
EDIT: Dave, I have numbered the steps of your migration process. Please check the encoding of your MySQL database at two points - right after step 1 (before you do the export & import) as well as after you export & import in step 3. This will have to detect the exact point where it went wrong.
server: RHEL 5.5, 2.6.18-194.el5, MySQL 5.0.77
client: Win 7 Corporate x86, MS Excel 2010, MySQL ODBC 5.2w Driver
On the server, mysql base test, and there is a table rr. Every time insert.sh is launched it truncates test.rr and writes new values to it. What I need is excel to get this data.
So I connect with ODBC driver to the base with select and everything works fine, the values writes to columns in excel, but only when I don't use cyrilic letters (and I really need to use them).
When I do, the output is like "ровалоÑÑŒ п". This is UTF-8 → CP1252, I suppose.
So, my guess is, the excel is using only cp1252. I tried to drop db and create it again with CHARACTER SET latin1 (this is the mysql name for cp 1252, right?), and after that did the same with the table, but I'm still getting the same output.
I also changed character set in MySQL connector to latin1, but still no luck.
Is there something I'm missing?
The charset of the Excel-file is UTF-8? For save your Excel-file with this charset try:
Save as… → Service → Charset
I need to transfer my mysql DB from windows server to Ubuntu server.
So i made export in phpmyadmin on win and imported *.sql file in linux.
In linux PMA all looks okay, tables are healthy, no errors, and charter set is (cp1251), russian data in tables looks how it needed.
But when i try to run select in php script there is only "???????" in result, and echo mysql_client_encoding() showing that charset is latin1.
Please, tell me where is latin1 can be seted?
Thanks for help.
UPD: I am using now mysql_set_charset('cp1251'); after each db connection, but its not an pefect solution. Maybe someone can offer other idea?