I use the database mysqldump utility to dump the database on the test server.

mysqldump --host=127.0.0.1 --skip-add-drop-table --skip-add-locks --no-create-info --user=root --password='root' stead > tead.sql 

In production for import I use:

 mysql --user=root --password='root' test < afostead.sql 

Also on the crown starts.

The following information gets into the dump file.

 INSERT INTO `im_gruppy` VALUES (100,'Бумага для оргтехники',1,'100.png',1); 

The problem is that when insert, when it finds duplicate entry '1' for key 'PRIMARY', the import stops. And I would like to update the old records.

Tell me how you can use mysqldump and mysql to do update strings and if there is no line then insert?

    1 answer 1

    Here is an example of the request, you will understand further

     INSERT INTO `table` (id, name, age) VALUES(1, "A", 19) ON DUPLICATE KEY UPDATE name="A", age=19 

    mysqldump --host = 127.0.0.1 --skip-add-drop-table --skip-add-locks --no-create-info --replace --user = root --password = 'root' stead> tead. sql

    • Re-read what it is about! I know about these requests without you. - Sergey Andrianov
    • Dump with these flags --insert-ignore Insert rows with INSERT IGNORE. --replace Use REPLACE INTO instead of INSERT INTO. - madfan41k
    • Thank you very much))) mysqldump --host = 127.0.0.1 --skip-add-drop-table --skip-add-locks --no-create-info --replace --user = root --password = ' root 'stead> tead.sql. Yes, change the problem plz answer I will give you the answer. - Sergey Andrianov