【发布时间】:2017-05-23 16:22:38
【问题描述】:
我正在尝试使用 bash 脚本对 mysql 数据库进行请求。 我找到了这个例子:bash script - select from database into variable
当我尝试mysql mysql -u $user -p时
user@user:~$ mysql mysql -u $user -p
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 454
Server version: 5.7.18-0ubuntu0.17.04.1 (Ubuntu)
Copyright (c) 2000, 2017, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
这是查找。
但是当我尝试mysql mysql -u $user -p $pwd
user@user:~$ mysql mysql -u $user -p $pwd
mysql Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using EditLine wrapper
Copyright (c) 2000, 2017, 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.)
.......................................
connect-expired-password FALSE
我检查了$user 和$pwd 它们包含正确的用户名和密码。
我一定是做错了什么,但我不知道是什么。如何在 bash 脚本中向 MySQL 发出请求?为什么这个例子对我来说没有按预期工作?
你能帮忙吗?
【问题讨论】:
-
请正确标记。 MySQL 不是 Oracle。语法不同。