mysql to excel - wrong charset output - mysql

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

Related

Phpmyadmin MYSQL import: Certain characters are not imported

I am migrating a wordpress site from one server to another. I exported an sql dump from the old server and imported it into the new server database through phpmyadmin. But certain characters are not displayed correctly like the apostrophe and hyphen.
I figure this is because of the different database encoding present in the 2 servers. The old server has the character set encoding as utf8mb4_unicode_520_ci while the new server has the encoding latin1_swedish_ci.
I tried changing the "Character set of the file:" of the export dump by setting it to iso-8859-1 so that it would then get imported correctly into the latin1_swedish_ci but it gives an error during import of the SQL syntax.
How can I migrate the data here correctly?
Unless you have a specific reason to be using "latin1_swedish_ci" (and I can't imagine you do - it was the MySQL default at some point), you should not be using that at all. Change the character set encoding on the new server to match the former.

Mysql, coding database to UTF-8

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.

Encoding issues when migrating from MSSQL SQL Server to (Linux) MySQL

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.

After migrating db php returns latin1 charset, but in DB - cp1251

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?

How to change or conversion utf8_general_ci to binary in MySQL?

When I tested the new version (1.20wmf4) of MediaWiki I saw (see: screen capture) the following message about database character set:
In binary mode, MediaWiki stores UTF-8 text to the database in binary fields. This is more efficient than MySQL's UTF-8 mode, and allows you to use the full range of Unicode characters.
In UTF-8 mode, MySQL will know what character set your data is in, and can present and convert it appropriately, but it will not let you store characters above the Basic Multilingual Plane.
I've my own Wiki on the MediaWiki engine, but my tables are with utf8_general_ci collation. My question is: how to easily change the collation from utf8_general_ci to binary in an existing database?
My MediaWiki version: 1.19.0
My MySQL info:
Server: Localhost via UNIX socket
Server version: 5.1.52
Protocol version: 10
MySQL charset: UTF-8 Unicode (utf8)
I had to do something similar not too long ago and followed the instructions here: http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki#Latin-1_to_UTF-8_conversion. You basically have to export the database, replace utf8_general_ci with binary in the exported SQL, and then import the database again. The sed line in those instructions wasn't quite right but you can also manually edit your dumped SQL file and fix any instances of utf8_general_ci.