1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to mysql dump special characters?

Discussion in 'Site & Server Administration' started by postcd, Aug 3, 2017.

  1. #1
    Hello, currently i have FTP access to a web hosting account, i also have mysql credentials.
    My aim is to export mysql database so i am using php function:
    <?php exec('mysqldump --user=*** --password=*** --host=*** dbnamehere -r exp.sql'); ?>
    that does not create any file, but when used: > exp.sql
    it create file but with damaged special characters. By special characters i mean: ěščřžýáíé and similar. By damaged i mean replaced by ? or other strange chars.

    The resulting dump and the table with damaged chars contains among other:
    /*!40101 SET character_set_client = utf8 */;
    ) ENGINE=InnoDB AUTO_INCREMENT=348 DEFAULT CHARSET=utf8;

    i tried to add this switch to mysqldump:
    --default-character-set=latin1
    --default-character-set=utf-8

    but still damaged chars. which command to run please to have working dump?

    UPDATE: i see that the command mentioned above somehow worked and created file. Even the file had wrong characters in it, i downloaded it via web browser and imported other hosting account mysql via PHPMyAdmin (left encoding set to UTF-8 on PHPMyAdmin Import tab. and it imported it successfully and seems no problem with chatractes. So this topic seems SOLVED, unless someone have an advice for future dumps.
     
    Last edited: Aug 3, 2017
    postcd, Aug 3, 2017 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    I'm guessing the file itself doesn't have wrong characters, but whatever you're using to view the file isn't using UTF-8 as default character set, hence the ? replacement. Or your environment isn't set up using UTF-8.
     
    PoPSiCLe, Aug 5, 2017 IP
    postcd likes this.