Strange 'source' commond in MySQL
Thursday, July 30th, 2009Need a PHP tool to import files dumped by mysqldump, I try this code:
DB::query("source /myFile.sql");
But a syntax error was given.
Some one said "Note that the 'source' command used in the mysql client program is *not* a feature of the server but of the client. This means that you cannot do mysql_query('source myfile.sql');".
I tried many ways to import the file, at last the only way can work:
$command = "mysql -u $user -p $password -e 'SET NAMES utf8; \. myFile.sql' $dbname;";
`$command`;
`$command`;