MySQL How to import data from SQL file
Suppose you exported a SQL file from phpMyAdmin and you want to import to a local MySQL instance.
The data comes from a table post. You need to first delete the old table from your local instance.
drop table post;
Otherwise you get the duplicate entry error:
ERROR 1062 (23000) at line 53: Duplicate entry '91' for key 1
And then import the file, the table creation statements are already contained
The command to import the file is
mysql -uroot -p databasename < post.sql
If the file is big, you may get other errors like
ERROR 2013 (HY000) at line 729: Lost connection to MySQL server during query
Or
ERROR 2006 (HY000) at line 729: MySQL server has gone away
You need to change the size of max_allowed_packet , the default is 1M. Change it to like 160M.
MySQL
MySQL Basics
MySQL Maintain