0
votes

I'm running the following query from the command line in Raspbian:

mysql -u $NAME -p $PASS Tweets -e "SELECT count(*) FROM raw_tweets;"

And it is outputting the following. I'm sure it's a setting somewhere, but all of my searching has been fruitless. Thanks in advance for the help.

mysql Ver 14.14 Distrib 5.5.43, for debian-linux-gnu (armv7l) using readline 6.2 Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Usage: mysql [OPTIONS] [database]
  -?, --help          Display this help and exit.
  -I, --help          Synonym for -?
  --auto-rehash       Enable automatic rehashing. One doesn't need to use
                      'rehash' to get table and field completion, but startup
                      and reconnecting may take a longer time. Disable with
                  --disable-auto-rehash.
                  (Defaults to on; use --skip-auto-rehash to disable.)
  -A, --no-auto-rehash 
                  No automatic rehashing. One has to use 'rehash' to get
                  table and field completion. This gives a quicker start of
                  mysql and disables rehashing on reconnect.
  --auto-vertical-output 
                  Automatically switch to vertical output mode if the
                  result is wider than the terminal width.
  -B, --batch         Don't use history file. Disable interactive behavior.
                  (Enables --silent.)
  --character-sets-dir=name 
                  Directory for character set files.
  --column-type-info  Display column type information.
  -c, --comments      Preserve comments. Send comments to the server. The
                  default is --skip-comments (discard comments), enable
                  with --comments.
  -C, --compress      Use compression in server/client protocol.
  -#, --debug[=#]     This is a non-debug version. Catch this and exit.
  --debug-check       Check memory and open file usage at exit.
  -T, --debug-info    Print some debug info at exit.
 ....... (Abbreviated, above should give enough of an example)
1
Are these variables $NAME and $PASS defined somehere? Are you using linux or windows?Jorge Campos
Does your query even execute?Ciaran Liedeman
The actual username and password are in there, just omitted them, and it doesn't appear that the query is executing here. however, when I launch MySQL and run it from there, they query does executektrip

1 Answers

0
votes

Your syntax is almost right, you forgot the add the database name parameter. Try this:

mysql -u $NAME -p $PASS -e "SELECT count(*) FROM raw_tweets" yourDBname

If Tweets is your database name, try this:

mysql -u $NAME -p $PASS -e "SELECT count(*) FROM raw_tweets" Tweets

Where $NAME and $PASS is your username and password with grants both for the database and the table.

No need of the semicolon. If you are running just one select command.