以 php UTF-8 格式导出 sql

export sql in php UTF-8

我想导出 sql 文件中我的数据库的所有表,使用 php 编码 UTF-8 最好的方法是什么!密码是什么! 谢谢

在此之后开始查询:

$db = new MySQLi("host", "username", "password", "db");

if(!$db)
{
    die("your_error_msg" . mysqli_error($db));
}

$db->set_charset("utf8");'

编辑

<?php
    //ENTER THE RELEVANT INFO BELOW
    $mysqlDatabaseName ='xxxxxx';
    $mysqlUserName ='xxxxxxx';
    $mysqlPassword ='myPassword';
    $mysqlHostName ='xxxxxxxx.net';
    $mysqlExportPath ='chooseFilenameForBackup.sql';

    //DO NOT EDIT BELOW THIS LINE
    //Export the database and output the status to the page
    $command='mysqldump --opt -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p' .$mysqlPassword .' --default-character-set=utf8 ' .$mysqlDatabaseName .' > ~/' .$mysqlExportPath;
    exec($command);
 ?>

发件人:export database using php code in .sql Extension?,但我添加了 --default-character-set=utf8 部分