我正在尝试使用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
发出请求?为什么这个例子对我不起作用?
你能帮忙吗?