Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysqldump update table

Tags:

mysql

I use the mysqldump utility to dump the database on the test server, which runs on the crown.

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

 On production for import use:

    Mysql --user = root --password = 'root' test

It also starts on the crown.

The dump file contains approximately the following information.

 INSERT INTO im_gruppy VALUES (100, 'Paper for office equipment', 1, '100.png', 1);

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

Prompt as it is possible by means of mysqldump and mysql to do update lines and if a line is not present that insert?

like image 913
Sergey Andrianov Avatar asked May 23 '17 09:05

Sergey Andrianov


People also ask

How do I use Mysqldump table?

mysqldump includes all the tables of the database by default. In order to dump only a specific set of tables using mysqldump , you need to specify the database name followed by the name of the tables you want to include in the dump. After running the command from the example above, the output file my_backup.

Does Mysqldump lock table?

By default, mysqldump locks all the tables it's about to dump. This ensure the data is in a consistent state during the dump.

How do I edit a MySQL dump file?

When mysqldump is created with –databases or –all-databases option, it will add “CREATE TABLE” and “USE” statements. If you need to restore the dump into different database (different name) you need to remove those statements. For small files it's not a problem - just edit the dump with your favourite text editor.

Does Mysqldump drop table?

mysqldump can retrieve and dump table contents row by row, or it can retrieve the entire content from a table and buffer it in memory before dumping it. Buffering in memory can be a problem if you are dumping large tables. To dump tables row by row, use the --quick option (or --opt , which enables --quick ).


1 Answers

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

like image 154
Sergey Andrianov Avatar answered Nov 07 '22 14:11

Sergey Andrianov