I want to export all of tables of my db in sql file using php with encoding UTF-8 whats the best way! whats the code! thank you
Asked
Active
Viewed 327 times
1 Answers
1
Start your query after this:
$db = new MySQLi("host", "username", "password", "db");
if(!$db)
{
die("your_error_msg" . mysqli_error($db));
}
$db->set_charset("utf8");'
EDIT
<?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);
?>
From: export database using php code in .sql Extension?, but I added the --default-character-set=utf8
part

Community
- 1
- 1

solid_luffy
- 361
- 2
- 15
-
i know that , my problem is exporting... whats the code for export a db as .sql file – Pedramch Jun 03 '15 at 19:23
-
Ah. I read it quickly so I misunderstood. Hehe. check my edit – solid_luffy Jun 03 '15 at 21:14