mysql -B -N -e 'SELECT COUNT(*) FROM users;' mydb

Category: Databases & SQL

mysql -B -N -e 'SELECT COUNT(*) FROM users;' mydb

Print bare query output for scripts

-B batch mode produces tab-separated rows and -N drops the column names, so the output is just the count. Add -r for raw bytes. The MySQL counterpart of psql -Atc. Related: mysql -t for table formatting.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.