Search code examples
mysqlrecordsmysqlimport

MySQL: Missing some records in mysqlimport


I am importing data into InnoDB table with huge number of records. The command mysqlimport says successfully imported as shown below. I am importing the data on an empty table.

C:\xampp\mysql\bin>mysqlimport.exe --fields-terminated-by=',' 
--columns="invoice_id,customername,department,city" --local -u root -p invoice11954 "c:\11954\invoice.txt"

Enter password:
invoice11954.invoice: Records: 1540252  Deleted: 0  Skipped: 0  Warnings: 0

But when I check the count of records in the table invoices, I see only 1534408 records. I have truncated the table and reimported again and again. There is always a mismatch in the record count and difference of records is not always constant.

Is it something to do with my configuration? I have given high values for configuration but still no luck.

# The MySQL server
[mysqld]
port= 3306
socket = "C:/xampp/mysql/mysql.sock"
basedir = "C:/xampp/mysql" 
tmpdir = "C:/xampp/tmp" 
datadir = "C:/xampp/mysql/data"
pid_file = "mysql.pid"
# enable-named-pipe
key_buffer = 32M
max_allowed_packet = 32M
sort_buffer_size = 1024K
net_buffer_length = 16K
read_buffer_size = 512K
read_rnd_buffer_size = 1024K
myisam_sort_buffer_size = 16M
log_error = "mysql_error.log"

[mysqldump]
quick
max_allowed_packet = 128M

My configuration doesn't have this section [mysqlimport]

Can someone help me what's going wrong here.


Solution

  • How are you checking the "count of records" in the invoices table? Obviously, we're assuming that you're executing a SQL statement like this:

    SELECT COUNT(*) FROM invoice ;
    

    And that you aren't relying on the estimated number of rows in information_schema.tables to give you a precise count.


    There's not enough information in the question, in its current form to give an answer for the behavior you are observing. As I noted in my comment, it's not clear whether the table has any unique constraints, of whether you've specified the --replace or --ignore options, because we don't see the command you are running, the [mysqlimport] section of the my.cnf file, or how you are checking the number of rows on the table after it's loaded.