从SQL shell脚本插入

qzwqbdag  于 2023-01-31  发布在  Shell
关注(0)|答案(1)|浏览(111)

晚上好
我试图在脚本中将数据从一个表插入到另一个表中,但却发现数据库未找到--我做错了什么吗?

mysql -e INSERT INTO mysql.db SELECT * from "$cpuser"_mysql.db;

CPUser是在脚本前面手动分配的变量。
在CLI中,我可以从两个选项中选择 *
注解输出;

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''domain7mysql4'_mysql.db' at line 1
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''domain7mysql4'_mysql.user' at line 1
jchrr9hc

jchrr9hc1#

-se需要字符串,因此您需要提供一个字符串

mysql -e "INSERT INTO mysql.db SELECT * from `$cpuser_mysql`.db;"

mysql -e "INSERT INTO mysql.db SELECT * from $cpuser_mysql.db;"

如果没有保留文本

相关问题