How to take mysqldump with UTF8?

I am trying to take mysql dump with the command:

mysqldump -u xxxx -p dbxxx > xxxx270613.sql

What is the command to invoke mysqldump with UTF8?

+5
source share
2 answers

Hi, please try the following.

mysqldump -u [username] –p[password] --default-character-set=utf8 -N --routines --skip-triggers --databases [database_name] > [dump_file.sql]
+8
source

--default-character-set=utf8 is the option you are looking for that you can use with these others:

mysqldump --events \
 --routines \
 --triggers \
 --add-drop-database \
 --compress \
 --hex-blob \
 --opt \
 --skip-comments \ 
 --single-transaction \
 --skip-set-charset \
 --default-character-set=utf8 \
 --databases dbname > my.dump

Also, check --hex-blobthis helps --hex-blobbinary strings in hexadecimal so that I can guarantee (to be more portable) import execution.

The option --databasescauses all names on the command line to be treated as database names. Without this option, mysqldumptreats the name as the database name, and the following as table names.

--all-databases --databases mysqldump CREATE DATABASE USE . , , , , , , . , , --add-drop-database. mysqldump DROP DATABASE CREATE DATABASE.

:

# mysql < dump.sql

:

# mysql dbname < dump.sql 
+5

Source: https://habr.com/ru/post/1695090/


All Articles