Hi

I have a linux server with mysql installed.There is some data in mysql tables.
Also.I have a .csv file (not from the aforementioned database)
I need to compare the data in the database nad the .csv and print out the difference.

I tried writing a shell script for that but I was unsuccessful.

I need to ask if there's any way I can export the data from mysql tables to .csv file format and use the diff command to see the comparison of the generated file and the file I had initially.

~thanks

Member Avatar for 1stDAN

You can temporally load the csv into another database table. Then compare your existing table with temporary table.

If you only look for different or missing rows, this can be done with right/left joins or with intersection (intersection must be simulated on mysql using union over two selects).

There is also a tool mysqldbcompare that shows all differences between two databases. In this case existing and temporary table must be located in two different Databases, and nothing else.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.