mysql shell脚本出错,'数据库:找不到命令'

时间:2021-01-07 23:57:21

I am getting the following error while trying to execute this command:

我在尝试执行此命令时收到以下错误:

Command:

$(mysql -u root -proot -e 'show databases;') > dbnames

Error:

Database: command not found

1 个解决方案

#1


0  

$( mysql -u ... ) evaluates to the result of the mysql command. In this example, that string is then treated as a command to execute, and so equivalent to trying to run

$(mysql -u ...)计算mysql命令的结果。在此示例中,该字符串然后被视为要执行的命令,因此等同于尝试运行

$ Databases > dbnames
Databases: command not found

You simply want to execute the mysql command:

您只想执行mysql命令:

mysql -u root -proot -e 'show databases;' > dbnames

#1


0  

$( mysql -u ... ) evaluates to the result of the mysql command. In this example, that string is then treated as a command to execute, and so equivalent to trying to run

$(mysql -u ...)计算mysql命令的结果。在此示例中,该字符串然后被视为要执行的命令,因此等同于尝试运行

$ Databases > dbnames
Databases: command not found

You simply want to execute the mysql command:

您只想执行mysql命令:

mysql -u root -proot -e 'show databases;' > dbnames