mysqldump --no-create-info -uxxxx -pxxxx Database ATable | gzip -9 > xxxx.sql.gz
zcat xxxx.sql.gz | mysql -uxxxx -pxxxx Database
mysqldump --no-create-info -uxxxx -pxxxx Database ATable | gzip -9 > xxxx.sql.gz
zcat xxxx.sql.gz | mysql -uxxxx -pxxxx Database
Tags: admin, backup, cli, command, dump, linux, mysql, mysqldump, restore, server, sysadmin, zcat
Posted in Code, Systems | No Comments »
If you ever need to see the SQL that Zend DB has created, so that you can run it manually or any other reason, here’s how to do it.
[php]
// Turn on the profiler
$db->getProfiler()->setEnabled(true);
// Run your query
$db->update(‘someTable’, array(
‘thisField’ => 0.12551,
‘anotherField’ => ‘xxxxxxxxxxxx’
), ‘whatId = ‘ . $cdsDB->quote(‘james’));
// Output the last query
echo "\n" . $db->getProfiler()->getLastQueryProfile()->getQuery() . "\n";
// And the parameters for it
print_r($db->getProfiler()->getLastQueryProfile()->getQueryParams());
// Then turn the profiler off, unless you want to do more
$db->getProfiler()->setEnabled(false);
/*
And the output is
UPDATE `someTable` SET `thisField` = ?, `anotherField` = ? WHERE (whatId = 186459)
Array
(
[1] => 0.12551
[2] => xxxxxxxxxxxx
)
*/
[/php]
Tags: dump, profile, query, sql, statement, zend, zenddb
Posted in Code | No Comments »