I am trying to truncate the database table using n98-magerun2 version 3.2.0 and having some difficulties.

I know there is a command with option to run an SQL query:

db:query Executes an SQL query on the database defined in env.php

I had a look at this blog entry, however, the result is a bit different: https://alanstorm.com/n98-magerun-database-commands/

Even simple SELECT is not working. When I run:

n98-magerun db:query "SELECT * FROM cms_page"

I get following error:


Too many arguments, expected arguments "command" "query".

Any help will be appricaited.

2 Answers 2


you can try to run it non-interactive, request for command prompt, then enter your query:

#!/usr/bin/expect -f

# Get a shell
spawn n98-magerun db:query

# Wait for a prompt
expect "SQL Query:"

# Type something
send "SELECT * FROM cms_page\r"


or if you can try to use singles, not double quotes:

n98-magerun db:query 'SELECT * FROM cms_page'

or just enter command, then enter your query in prompt:

n98-magerun db:query

Why not just truncate the table via mysql cli directly?

mysql -u root -p'' magento -e 'truncate table `magento`.`table_to_truncate`'
  • That's what I did at the end, but I wanted to know if there is a way of doing it using the MageRun :P
    – Greg
    Commented Aug 30, 2019 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.