How to change encoding of the mysql dump files - mysql

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.

Related

Mysql ERROR: ASCII '\0' while importing sql file on linux server

I am getting following error while importing sql file
ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode.
Set --binary-mode to 1 if ASCII '\0' is expected. Query: ''.
How do I fix this?
Try something like :
mysql -u root -p -h localhost -D database --binary-mode -o < dump.sql
and make sure your sql file is not zipped.
I encountered this problem,the sql file was in a valid ISCII format, I solved as the following:
1- in shell use file command to detect type of data contained in the dump file:
file db.sql
got output like following:
db.sql: Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators
2- convert the existing dump file to UTF8 (ASCII) using iconv:
iconv -f utf-16 -t utf-8 db.sql > db_utf8.sql
then import the new file.
I just had this issue because the file was gzipped. I unzipped it and had no further issue.
Adding to it:
Path to db also should be configured correctly. Considering you are running find command on mac then use sudo and unzipped data file name could be put in below code at the place of [some_name_of_data.sql]
sudo find / -name [some_name_of_data.sql] -type d
or if you don't have sudo access as working in some company system then use below command:
find / -name [some_name_of_data.sql]
And something like this (eg.
fin sqli /System/Volumes/Data/Users/clinto.abraham/projects/sme/Data/react-dev-2022-08-02.sql ) could be used to set the data in a docksal environment.
fin sqli [some_path_to_db]

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.

mysql dump - character encoding

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

mysqldump with character issues

php code:
exec('mysqldump --opt --compress --host='.DB_HOST.' --user='.DB_USER.' --password='.DB_PASS.' '.DB_NAME.' > file.sql');
some characters are not being exported as they are in the DB. For example "ñ" becomes "ñ" -- am i missing a parameter in the mysqldump instruction? BTW, the DB is utf8. thanks!
See this question: How to keep special characters when running ./mysqldump?
Try adding the switch: --default-character-set=UTF8