Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

truncate table via command line in Linux

I want to truncate one of my db table using mysqldump command so that I can place that command in sh file for executing it on daily basis. Do any one know about this command? Thanks in advance

like image 816
Neha Mangla Avatar asked May 03 '14 08:05

Neha Mangla


2 Answers

You can use mysql command line client to do it

mysql -h dbserver_hostname -e "truncate table schema_name.table_name"
like image 85
Michael Kruglos Avatar answered Nov 11 '22 17:11

Michael Kruglos


localhost=hostname
root=username
''=password
demo=db name
language=table name   

#to truncate a table from database
mysql -h localhost -u root -p'' demo -e "truncate table demo.language"
like image 40
Shal Avatar answered Nov 11 '22 17:11

Shal