我正在使用InfiniDB(不是通過選擇)。當我使用Linux shell中,我能夠連接到數據庫就好了:mysql在登錄時掛起
<user>@<host>:~$ /usr/local/Calpont/mysql/bin/mysql -u <user> -p -h <host>
Enter password: <password>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1725
Server version: 5.1.39 MySQL Community/Calpont InfiniDB Community 2.2.11-1 Fin al (COSS LA)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use <database_name>
Database changed
mysql>
但是當我使用一個bash腳本,它掛起:
<user>@<host>:~$ bash -x /home/aliceell/db_export.sh
+ DB=al05_09
+ export_dir=/tmp/
++ /usr/local/Calpont/mysql/bin/mysql -u <user> -p -h <host> <db_name>
Enter password:
它停止我進入後響應我密碼並按'enter'。我必須使用Ctrl-C來擺脫它。
這裏是我的代碼:我是新來bash和試圖將它通過所有的表在我的數據庫使用循環和導出它們(similar to this script)
DB=<db_name>
export_dir="/tmp/"
err_exit()
{
echo -e 1>&2
exit 1
}
mysql_data_dir=$(/usr/local/Calpont/mysql/bin/mysql -u <user> -p -h <host> <db_name>) #it hangs at this stage
if ! (mysqlshow $DB 1>/dev/null); then
echo ERROR: unable to access database
exit 1
fi
echo "connected"
if ! [ -w $export_dir ]; then
echo ERROR: export dir is not writable
exit 1
fi
ExportTable()
{
/usr/local/Calpont/mysql/bin/mysql -u <user> -p -h <host> <db_name>"
SELECT * INTO OUTFILE '/tmp/$T.csv'
FIELDS TERMINATED BY '|'
LINES TERMINATED BY '\n'
FROM $T
"
}
/usr/local/Calpont/mysql/bin/mysql -u <user> -p -h <host> <db_name> "show tables" |
while read T; do
echo exporting $T
ExportTable || err_exit
sudo mv $mysql_data_dir/$DB/$T.psv $export_dir/ || err_exit
done
,但也沒有用如果我甚至不能連接到數據庫...
在此先感謝您的幫助。
db_export.sh實際上看起來像什麼? – chepner
它看起來像我在帖子中鏈接的腳本。我編輯了我的帖子以包含代碼。除了我必須使用/ usr/local/Calpont/mysql/bin/mysql而不是僅僅使用mysql,因爲這就是它對於infinidb(afaik)的作用。 – ale19