I_G
I_G

Reputation: 413

Backup mysql table

What's the better way to do a back up of a sql table in the linux server

I do this way :

Create table backuptablecustomer like customer

insert into backuptablecustomer select * from customer

But is there another way?

Upvotes: 0

Views: 73

Answers (3)

Mark
Mark

Reputation: 56

The mysqldump utility will produce a text file with SQL commands that can then be used to restore the tables and data.

See https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html.

E.g.

mysqldump -u user -p db_name customer > customer.sql

Upvotes: 3

I_G
I_G

Reputation: 413

Ok thanks thats the command I did and it works :

C:\wamp\bin\mysql\mysql5.6.17\bin\mysqldump -u user -p db_name customer > customer.sql

Upvotes: 1

gen_Eric
gen_Eric

Reputation: 227310

If you need to back up the table using an SQL query, then you can try using SELECT ... INTO OUTFILE.

SELECT * FROM customer INTO OUTFILE '/path/to/backups/customer.sql';

Upvotes: 1

Related Questions