gpt4 book ai didi

mysql转储: Couldn't find table: "|"

转载 作者:行者123 更新时间:2023-11-29 04:45:56 25 4
gpt4 key购买 nike

我尝试执行 exp 文件:

#!/usr/bin/expect

# mysql credentials and connection data
current_db_name='webui_dev'
new_db_name='db_2013'
db_host='localhost'
db_user='root'
db_pass=''


# using a here-document to pass commands to expect.
# (the commands could be stored in a file as well)
expect <<EOF
log_user 0
spawn mysqldump -h "$db_host" -u "$db_user" -p "$current_db_name" | mysql -h "$db_host" -u "$db_user" -p "$new_db_name"
expect "password:"
send "$db_pass\r"
log_user 1
expect eof
EOF

我用 -f 标志执行 if,我得到一个错误:mysqldump: Couldn't find table: "|"

如果我尝试这种方法

exp_internal 1
spawn sh -c "mysqldump -h \"$db_host\" -u \"$db_user\" -p \"$current_db_name\" | mysql -h \"$db_host\" -u \"$db_user\" -p \"$new_db_name\" "

我得到一个输出

expect: option requires an argument -- f
usage: expect [-div] [-c cmds] [[-f] cmdfile] [args]
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {81914}

expect: does "" (spawn_id exp7) match glob pattern "password:"? no

expect: does "Enter password: " (spawn_id exp7) match glob pattern "password:"? yes
expect: set expect_out(0,string) "password:"
expect: set expect_out(spawn_id) "exp7"
expect: set expect_out(buffer) "Enter password:"
send: sending "\r" to { exp7 }

Enter password: expect: timed out

最佳答案

当 Johannes 说使用 shell 时,他的意思是:

  spawn sh -c "mysqldump -h \"$db_host\" -u \"$db_user\" -p \"$current_db_name\" | mysql -h \"$db_host\" -u \"$db_user\" -p \"$new_db_name\""

关于mysql转储: Couldn't find table: "|",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18934492/

25 4 0