Activity

  • hipo posted an update 5 years, 4 months ago

    How to dump UTF-8 safely – Dumping safely

    Copy
    # Do not do this, since it might screw up encoding
    mysqldump -uroot -p database > utf8.dump # this is bad

    Better do:

    Copy
    mysqldump -uroot -p database -r utf8.dump

    Note that when your MySQL server is not set to UTF-8 you need to do mysqldump –default-character-set=latin1 (!) to get a correctly encoded dump. In that case you will also need to remove the SET NAMES=’latin1′ comment at the top of the dump, so the target machine won’t change its UTF-8 charset when sourcing.

    If you only want to dump the structure without data, use

    Copy
    mysqldump -uroot -p –no-data database -r utf8.dump

    Importing a dump safely

    Copy
    # Do not do this, since it might screw up encoding
    mysql -u username -p database SET names ‘utf8’
    mysql> SOURCE utf8.dump

PC Knowledge sharetank

Skip to toolbar