因此,我對數據庫非常陌生,但是我已經完成了一些研究,並且我認爲我已經弄清楚了需要的所有內容,但是當我嘗試運行時遇到錯誤我的腳本。只有在通過Bash腳本運行時纔會出現Mysql錯誤
這是我的腳本
mysql -h portal-rds -u $user --password=$mysqlpw <<QUERY_INPUT
CREATE DATABASE IF NOT EXISTS $DATABASE
use $DATABASE
CREATE TABLE IF NOT EXISTS backUpFiles (fileName VARCHAR(20), archiveId VARCHAR(500), checkSum VARCHAR(100), glacierVault VARCHAR(100), timeStamp date);
INSERT INTO backUpFiles
VALUES ('$archive_file_name', '$archiveID', '$CURRENTVAULT', '$checkSum', CURDATE());
QUERY_INPUT
我recieving的錯誤是
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 'use glacier
CREATE TABLE IF NOT EXISTS backUpFiles (fileName VARCHAR(20), archiveId VARCHAR(500), checkSum VARCHAR(100), glacierVault VARCHAR(100), timeStamp date);
Query OK, 0 rows affected, 1 warning (0.00 sec)
我於是決定手動登錄到MySQL並運行此命令,他們工作得很好,除了這一個警告,這不該(我相信)
mysql> show warnings;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1050 | Table 'backupfiles' already exists |
+-------+------+------------------------------------+
1 row in set (0.28 sec)