I'm trying to truncate one of my table in my database.
database name : site-local table name : cloud_securities
mysql -u root -p'' -h localhost site-local -e "truncate table site-local.cloud_securities"
After enter my password, I kept getting
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-local.cloud_securities' at line 1
What can I try to resolve this?
The commandline has trouble with the dashes in the db and tablenames.
You can however access the client and then send your statement, have to put the db and table in backticks.
mysql -u root -h localhost
truncate table `site-local`.`cloud_securities`;
edit: nvm, you can do it from the commandline by using backticks, but you have to escape them.
Solution:
mysql -u root -p'' -h localhost site-local -e "truncate table \`site-local\`.\`cloud_securities\`"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With