MySQL从命令行

时间:2015-09-12 19:27:19

标签: mysql

我正在Raspbian的命令行中运行以下查询:

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

输出以下内容。我确定这是某个地方,但我所有的搜索都没有结果。在此先感谢您的帮助。

  

mysql Ver 14.14使用readline 6.2为debian-linux-gnu(armv7l)分发5.5.43   版权所有(c)2000,2015,Oracle和/或其附属公司。保留所有权利。

     

Oracle是Oracle Corporation和/或其注册商标   分支机构。其他名称可能是其各自的商标   所有者。

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 个答案:

答案 0 :(得分:0)

您的语法几乎是正确的,您忘记了添加数据库名称参数。试试这个:

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

如果Tweets是您的数据库名称,请尝试以下操作:

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

$NAME$PASS是您的用户名和密码,同时授予数据库和表格。

不需要分号。如果您只运行一个选择命令。