mysql dump - character encoding - mysql

I have a mysql dump what contains ascii characters like überprüft. My problem is like I can not make another dump and I have been searching on the net for a solution but every suggestions would involve another dump set it up to utf-8. Is there a way to convert a dump file.

Is the entire dump encoded like that, that is, in UTF-8? In that case you can simply set the encoding when you import the dump.
If you use the mysql command line client to import the dump, use the --default-character-set command line switch when importing, for example:
> mysql -u user --default-character-set=utf8 < dump.sql

Related

MySQL database with wrong character set and LONGTEXT's with binary data

I have Percona XtraDB 5.6 server with very old database with charset set to utf8 and data encoded in different charset (probably latin1).
I tried to migrate the database to new Percona 8.0 server but after importing the SQL file, all diacritic marks become broken on the 8.0 server. I have resolved the issue by executing this query on every column in every table:
UPDATE table SET col = convert(cast(convert(col using latin1) as binary) using UTF8) WHERE 1;
BUT there is one table with binary data (specifically GZIP compressed data) saved into LONGTEXT columns. Data from this columns always becomes damaged after import on the new server.
This is what I tried so far:
changing column type to LONGBLOB before dump.
using the above query to convert the data before/after column type change.
This is the command I'm using to export DB:
mysqldump --events --routines --triggers --add-drop-database --hex-blob --opt --skip-comments --single-transaction --skip-set-charset --default-character-set=utf8 --databases "%s" > db.sql
Please note the "--hex-blob" option which still results in binary data being exported as strings, instead of hex.
It would not have been damaged by zip/unzip. But it could have been damaged in any of a number of other ways.
"--hex-blob" turns data into strings such that they will not be mangled until you reload them.
Dumping, loading, INSERTing, SELECTing all need to be told what character set to use.
The particular UPDATE you did may or may not have made things worse. Here is a list of cases that I have identified, and the minimal "fix":
http://mysql.rjweb.org/doc.php/charcoll#fixes_for_various_cases

How to fix a mysql dump file if it has blob field but dump without use --hex-blob parameter?

I use MySQL 5.5 and dump a database. But I forget that this database has some blob filed!
I use MySQL dump command to dump the database, without use the hex-blob parameter! So, after i get the file, I can't import to my MySQL, it is said that unknown command. But i have to import the data to my another MySQL server. How can i repair this database?
myqldump -u root -p -h localhost abc>c:\abc.sql
as you see, I forget use the --hex-blob parameter!
If *nix, have you tried to load `mysql abc
But, since this is Windows, you have probably been screwed by NL turning into CRLF.

MySQL: Special chars and umlauts broken after exporting/importing dump?

I built a website locally using xampp. Now I want to put it on my server. I uploaded the code and now its time to import the database. So I exported it locally on the command line using:
mysqldump -hlocalhost -udb123456 -p123456 db123456 -e --default-character-set=utf8 > backup.sql
Now I created a new database on the server and imported this file using phpmyadmin on the server. The char set was set to utf-8 in phpmyadmin. When I open my site now, special chars like ü or € are shown as ü for example.
I can not import the dump using a console on the server, I may only use phpmyadmin.
What did I do wrong?
Thanks!
I had a similar problem. I solved it in the PHP code, as described here
PHP PDO: charset, set names?
(assuming you use PDO)

mysqldump to csv in utf8

I'm using the following command to export data from my database to csv:
mysqldump -u root -p -T/home/xxx/stock_dump -t --fields-terminated-by=";" products stock
But the database is in UTF-8 and this command exports UTF-8 characters incorrectly, e.g.
ŻYWIEC ZDRÓJ is ĂÂťYWIEC ZDRĂâJ
How do I export it in the correct UTF-8 format?
Adding --default-character-set=utf8 did not help at all.
Or if it is not possible, how do I postprocess it the easiest way? Can iconv do anything about it?
mysqldump produces UTF-8 encoded dumps unless told otherwise (or unless you use a really, really old version of mysqldump -- anyways, your correct using of --default-character-set=utf8 settles it).
Either your text editor is not recognizing UTF-8 correctly, or the data in the database is already wrongly encoded.

How to change encoding of the mysql dump files

How to change encoding of the mysql dump files?
When I run mysqldump command it creates file encoded in ANSI. How to change it to utf-8? I have also tried to do this:
mysqldump --user=user1--password=pas1 --default-character-set=utf8 mydb1 mytbl1 > e:\1.sql
According to this forum thread, the culprit is the > filename redirection on Windows, which seems to have trouble with UTF-8 characters.
Try using the --result-file parameter instead.