How to log the error and warning while restoring the SQL dump on MySQL ?
Following are the steps we were doing.
mysql> CREATE DATABASE dbname;
mysql> USE dbname;
mysql> SOURCE dbdumpname.sql
databaseMySQLmysqldumpsql
How to log the error and warning while restoring the SQL dump on MySQL ?
Following are the steps we were doing.
mysql> CREATE DATABASE dbname;
mysql> USE dbname;
mysql> SOURCE dbdumpname.sql
Best Answer
To redirect MySQL errors and warnings to a log file, restore the SQL dump from bash not from a MySQL prompt.
If you need to supresss foreign key checks, create a shell script named
mysql-import.sh
and put the following contents in it:Then
chmod +x mysql-import.sh
to make the script executable and run the script as,./mysql-import.sh > /var/log/mysqldump.log 2>&1
This script will run the code that you were running in MySQL, but with the ability to redirect output to a log file, since it can be invoked from the shell.