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.
Related
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.
I want to convert my database to utf-8. What I have done up to now is set the server to read utf-8 and the database is converted by using this query:
ALTER DATABASE database_name CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Now all new information is seen and the things that were broken are now fine. The problem is that the old data is seen as �. This, in my opinion, is due to the fact that the old data is written in windows-1251 (I think at least and I am not 100% sure).
I found out that I need to dump the data:
mysqldump -uroot -p database -r utf8.dump
and then import it:
mysql -uroot -p --default-character-set=utf8 database
mysql> SET names 'utf8'
mysql> SOURCE utf8.dump
This is what I saw from here: https://makandracards.com/makandra/595-dumping-and-importing-from-to-mysql-in-an-utf-8-safe-way
The problem is that I have absolutely no idea where and how to do this.
All I have access is to the web hosting control panel and I have not set up anything on my computer. Therefore, I have no idea how to connect the database to the command shell and so on. What next steps should I do to convert the data to utf-8? Please, any detailed explanation would be great due to the fact that this is the first time for me doing something like this.
// I have a Mac and a Windows machine, but not a Linux at the moment.
Thank you!
The charset and collation of the database are the default for any subsequently created tables. The table setting are the defaults for columns.
For each table, so this:
ALTER TABLE table_name CONVERT TO utf8mb4;
I want to move my MySQL database to an older version server (5.7 to 5.1).
I get errors because it is created using utf8mb4 .
If i manually change utf8mb4 to utf8 the data become unreadable because of multilinguality.
I have access only to phpMyAdmin in both servers so I can't use mysqldump.
Any ideas?
It seems I've figured out a solution.
Use at export mysql40 compatibility mode, replace utf8mb4 with utf8 and change the character set of tables from phpmyadmin to utf8_unicode_ci.
Hope this will save some time from a fellow in future.
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.
I've uploaded some data to a MySQL (5.5.15 for osx10.6) database using UTF8 encoding, though for some reason I had to specify its encoding as latin1 when I LOADed it.
I reckon this part is good because when I write to an OUTFILE, my unicode 'nu' characters come out OK in a terminal and in Vim.
However, when I look at them within a MySQL session, and when I try to edit the fields from Django admin, I get mangled characters (latin1?).
So, my question is: how to I tell a MySQL client and (especially) Django to read my database as UTF-8, the way it oughta?
At the command line, I tried
--default_character_set=utf8
and also
'SET NAMES UTF8;'
at the MySQL prompt, but they do not work.
When I look at VARIABLES LIKE 'char%', they're all set to utf8 apart from character_set_server which is latin1. If I set it to utf8.... that doesn't work either.
I'd be grateful if someone could give me some pointers here, especially about how to configure Django to talk to my database properly.
Thanks!
Add in your .cnf:
[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci
skip-character-set-client-handshake