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.
Related
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
Last week I migrated my db in another platform. I did a mysqldump export from phpmyadmin panel and then I imported it in a new platform using the bigdump script.
The sql dump file that I have imported was originally stored in a db that was setting in this manner:
MySQL charset: UTF-8 Unicode (utf8)
MySQL connection collation: utf8_unicode_ci
I exported the db choosing utf8 character set but if I look inside the mysqldump file for every table appears:
DEFAULT CHARSET=latin1
Now I have a problem with the accented letter (like à, è, ò, ì) that are displayed like ò , Ã...etc.
For manage my new db I use MySQL Workbench and if i prompt:
show variables like 'char%';
I see that all the values are set in utf8.
How can I solve the problem? I'm not a Mysql and db expert!
You can try changing the current character set of a table to the original:
alter table TABLE_NAME convert to character set utf8 collate utf8_unicode_ci;
Your tables seem to use latin1, despite the utf8 settings you mentioned. So you have several options here:
Take the created dump as is and send it to the server using the latin1 connection charset (not utf8). This will however create the tables with latin1 charset as they are on the source server.
Convert the dump to utf-8 if you have a tool that can do it. You have to change the charset settings for your tables in the script too, though.
Convert your tables to utf8 and do the dump again.
Combine 1 + 3, but convert your target tables instead. Useful if you cannot change the source tables.
Have you actually tried MySQL Workbench to restore the dump to your new server? I'm quite sure it should be able to handle this case with a latin1 encoded backup. See Server Administration section -> Data Import/Restore.
I've got a database that I want to export and import to another database on a different server, however after I've imported it I have character encoding issues i.e in some cases where there is a space in the html, a black diamond appears with a question mark inside.
I done the export a couple of months ago so can't remember if I simply imported the database via phpMyAdmin or used mysqldump! I'm going to re-import it today and wanted to know the best way to export and import. The HTML header on the website is utf-8, each database table has collation set to latin1_swedish_ci and the type is MyISAM.
The web server I am exporting from has the following settings:
MySQL charset: UTF-8 Unicode (utf8)
Apache/2.2.12 (Ubuntu)
MySQL client version: 5.1.37
PHP extension: mysqli
PhpMyAdmin Version information: 3.2.2.1deb1
The web server I am importing to has the following settings:
MySQL charset: UTF-8 Unicode (utf8)
Apache
MySQL client version: 5.5.24
PHP extension: mysqli
phpMyAdmin Version information: 3.4.10.1deb1
I would be grateful if someone can recommend the best way to export/import and if possible explain the reason behind the character encoding issues.
Thanks
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.