Skip to content

Instantly share code, notes, and snippets.

@CHERTS
Last active September 23, 2019 11:52
Show Gist options
  • Save CHERTS/ba66ba63b3a5d73841b7f37133c3e33f to your computer and use it in GitHub Desktop.
Save CHERTS/ba66ba63b3a5d73841b7f37133c3e33f to your computer and use it in GitHub Desktop.
Logging mysql import error
1) Run:
mysql -u root -p db_name < dumpfilename.sql > /var/tmp/mysqldump.log 2>&1
2) Or create file mysql-import.sh:
#!/bin/bash
mysql -u root -p'password' -h hostname db_name << EOF
CREATE DATABASE dbname;
USE dbname;
SET foreign_key_checks=0;
SOURCE dbdumpname.sql;
EOF
chmod +x mysql-import.sh
./mysql-import.sh > /var/log/mysqldump.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment